No, these aren't subnormal values, although they are small. Using %.16e does print them all accurately though, so that's a bit misleading. By "hang" I meant that it doesn't return quickly, not that it won't ever return.
On Wed, Nov 5, 2014 at 2:27 PM, Tamas Papp <tkp...@gmail.com> wrote: > I think that you are just running floats which are "subnormal" in a > fixed-point decimal representation: with "%.17f", they have (on average) > a single 0 after the decimal dot, with "%.18f", they have two, > etc. Printing them with %f but a fixed number of digits is not the right > way, since you waste digits on these zeroes. > > It should not hang at 21, except, of course, it will > take more time to generate a float below approx 1e-5. > > David's issue is different, and essentially boils down to > > julia> bits(1/Inf) > "0000000000000000000000000000000000000000000000000000000000000000" > > julia> bits(-1/Inf) > "1000000000000000000000000000000000000000000000000000000000000000" > > which are equal when compared with == (which follows the IEEE standard) > but not is(,) (which compares bits). > > Best, > > Tamas > > On Wed, Nov 05 2014, Stefan Karpinski <ste...@karpinski.org> wrote: > > > This code prints a random Float64 that requires more than 15 digits to > > reconstruct: > > > > while true > > x = rand() > > if parsefloat(@sprintf("%.15f", x)) != x > > println(x) > > break > > end > > end > > > > > > There are lots of them. What's more surprising is that if you replace 15 > > with anything up to 20, it still returns really quickly – at 21 it hangs. > > This implies that values requiring up to 20 digits to print "honestly" > are > > quite common. > > > > On Wed, Nov 5, 2014 at 1:53 PM, David van Leeuwen < > > david.vanleeu...@gmail.com> wrote: > > > >> I couldn't resist this after my cholfact() revelation... > >> > >> On Wednesday, November 5, 2014 11:23:03 AM UTC+1, Stefan Karpinski > wrote: > >>> > >>> Well, I'm not sure what the intention was, but this fact is true: for > >>> floating-point values x and y of the same type, x == y is true if and > only > >>> if string(x) == string(y). > >>> > >>> > >> julia> a = inv(eye(2)) > >> > >> 2x2 Array{Float64,2}: > >> > >> 1.0 -0.0 > >> > >> 0.0 1.0 > >> > >> julia> a[1,2] == a[2,1] > >> > >> true > >> > >> julia> string(a[1,2]) == string(a[2,1]) > >> > >> false > >> (pardon the formatting, I don't seem to have a good handle on this in > >> google groups) > >> > >> Cheers, > >> > >> ---david > >> > >