Re:Try Julia
by rebo on Sunday January 26, 2014 @04:28PM
(#7127023)
Is round(x) broken?
[ Parent
| on HN ]
Re:Try Julia
by KenoFischer on Sunday January 26, 2014 @05:43PM
(#7127391)
To give some context, several common math constants are use the MathConst type to provide multi-precision constants. This allows e.g. a*pi to be extremely accurate if a is, e.g. a BigInt.
This issue was also reported at https://github.com/JuliaLang/julia/issues/5561
round(x) only works for a few specialised types of x. help(round) tells you that it will return the same type then. Of course for a type of MathConst{:π}, that won’t work. For generic types, you need to at least specify the number of digits (round(pi, 3)). (See also: methods(round))
Weird that they have round(pi) as an example.