Re: nan/inf behaviour in ROOT

From: Philip Rodrigues <p.rodrigues1_at_physics.ox.ac.uk>
Date: Thu, 11 Mar 2010 10:51:53 +0000


It probably won't affect you, but there's a weird corner case when floating exceptions are turned on:

root [0] gSystem->SetFPEMask(kInvalid)
(Int_t)0
root [1] 1e99
(const double)9.99999999999999967e+98

The reason is because TCint::ProcessLine returns the return value of the command executed (ie 1e99) cast to an int. In this case it overflows an int, which is fine with FPEs off (the int value just wraps), but crashes with FPEs turned on.

Anyway, it's not really a bug, but it is something one might run into with FPEs turned on.

Phil

Vito Di Benedetto wrote:
> Hi Axel,
>
> Axel Naumann wrote:

>> Hi Vito,
>>
>> see http://root.cern.ch/root/html/TSystem#TSystem:SetFPEMask

>
> This is what I need :-)
>
> Thank you,
> Vito
>
>
>> Cheers, Axel.
>>
>> Vito Di Benedetto wrote on 03/11/2010 09:51 AM:
>>>   Dear ROOT experts,
>>>
>>>  I'm using ROOT 5.26.00. In this ROOT version I have an unexpected
>>> behaviour in handling float numbers.
>>>
>>> If I type the following instruction
>>>
>>> root [0] Float_t a = 0.
>>> root [1] Float_t b = 10.
>>> root [2] b/a
>>> (double)inf
>>> root [3] Float_t c = -10.
>>> root [4] TMath::Sqrt(c)
>>> (const double)nan
>>>
>>>
>>>  I don't get exception. I have just inf or nan.
>>>
>>>  The same happen on my framework based on ROOT. I prefer to get floating
>>> point exception instead of inf/nan. In this way I can check better in my
>>> framework if there some "strange Physics effect".
>>>
>>>  Please, there is some way to get back floating point exception?
>>>
>>> Cheers,
>>>     Vito
>>>
>>>
>>>

>
Received on Thu Mar 11 2010 - 11:52:03 CET

This archive was generated by hypermail 2.2.0 : Thu Mar 11 2010 - 23:50:01 CET