The == check works exactly the same way in Julia as it does in other
languages. It's the printing of the numbers that's more precise.

On Wed, Nov 5, 2014 at 2:41 AM, K Leo <[email protected]> wrote:

> I meant this: to check whether 2 floating point valuables equal I had
> always had to do something like abs(x-y)<1.e-5 (never simply x==y) in other
> languages.  I wonder whether checking x==y would be sufficient in Julia?
>
>
> On 2014年11月05日 09:30, Stefan Karpinski wrote:
>
>  On Wed, Nov 5, 2014 at 2:06 AM, K Leo <[email protected] <mailto:
>> [email protected]>> wrote:
>>
>>     julia> 2*10.97 + 23.9985
>>     45.938500000000005
>>
>>     julia> 2*10.97 + 23.9985 == 45.938500000000005
>>     true
>>
>>     Amazing.  I never expected this.  Is floating point comparison
>>     going to be guaranteed?
>>
>>
>> What's shocking about this? What do you mean by floating point comparison
>> being guaranteed? We always print individual floating-point numbers with
>> enough digits to reconstruct their exact value (moreover, they are always
>> printed with the minimal number of digits necessary to do so).
>> Floating-point arrays are printed truncated.
>>
>
>

Reply via email to