On Matlab R2013b:
>> 2*10.97 + 23.9985
ans =
45.9385
>> 2*10.97 + 23.9985 == 45.9385
ans =
0
>>
-- mb
On Tue, Nov 4, 2014 at 7:48 PM, Stefan Karpinski <[email protected]>
wrote:
> Some systems round their answers as John said but it's easy to check that
> it's a lie:
>
> R version 3.1.0 (2014-04-10) -- "Spring Dance"
> > 2*10.97 + 23.9985
> [1] 45.9385
> > 2*10.97 + 23.9985 == 45.9385
> [1] FALSE
>
> This is perl 5, version 16, subversion 2 (v5.16.2)
> DB<1> x 2*10.97 + 23.9985
> 0 45.9385
> DB<2> x 2*10.97 + 23.9985 == 45.9385
> 0 ''
>
>
> I don't have a working copy of Matlab right now, but I think it does this
> too.
>
> On Tue, Nov 4, 2014 at 8:31 PM, Neil Devadasan <[email protected]> wrote:
>
>> Thanks
>>
>> On Tuesday, November 4, 2014 2:13:37 PM UTC-5, John Myles White wrote:
>>>
>>> Hi Neil,
>>>
>>> Julie does math the same way that all computers do math. You're probably
>>> coming from another language where a lot of effort is invested into
>>> pretending that computers offer a closer approximation to abstract
>>> mathematics than they actually do. Those systems have been lying to you.
>>>
>>> Put another way: you just took the red pill by using Julia.
>>>
>>> -- John
>>>
>>> On Nov 4, 2014, at 11:06 AM, Neil Devadasan <[email protected]> wrote:
>>>
>>> > julia> f(x::Float64, y::Float64) = 2x + y;
>>> >
>>> > julia> f(10.97,23.9985)
>>> > 45.938500000000005
>>> >
>>> > The above method execution of function f returns an answer that I
>>> cannot understand. Can someone clarify?
>>> >
>>> > Thank you.
>>>
>>>
>