Version française
Home     About     Download     Resources     Contact us    
Browse thread
Floating-point classification
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Olivier Andrieu <andrieu@o...>
Subject: Floating-point classification
Hello, 

Is there a way to test whether a float has value 'nan' or 'inf' ? I
didn't find in the standard library the equivalent of libc functions
isfinite() or isnan() (those are macros I think). 

I think that in C you can test if a float is nan by comparing it
with itself. It seems to work in  OCaml too :

        Objective Caml version 3.00

# let a = 0. /. 0. ;;
val a : float = nan
# a = a ;;
- : bool = false

Is it correct ? What about 'inf' ?

   Olivier