R is not "more low-level", it just has a different default setting for
how many digits to display. Try (in R):
> options(digits=22)
> 1.1+0.1
[1] 1.200000000000000177636
Cf in Julia (note we ask for 21 digits after the decimal dot, because
of the leading 1.):
julia> @sprintf("%.21f",1.1+0.1)
"1.200000000000000177636"
Best,
Tamas
On Thu, Sep 03 2015, Michael Borregaard <[email protected]> wrote:
> OK, thanks - the website is really useful. I come from R, where the result
> is presented as 1.2 – I guess Julia is more low-level in its interface.
> (BTW I did of course search the forums before posting, but most have missed
> the question).
>
> Den torsdag den 3. september 2015 kl. 09.45.18 UTC+2 skrev Michael
> Borregaard:
>>
>> Hi,
>> in the Julia documentation, I fell over this strange behaviour:
>>
>> julia> 1.1 + 0.1
>> 1.2000000000000002
>>
>> I understand that this may make sense in the context of how floating
>> numbers are implemented inside Julia - but I cannot think of a single
>> situation in which the user would want this behaviour.
>> Can someone explain what is going on, and why this is not a bug?
>>
>> Thanks,
>> Michael
>>