I need to convert a Double to a CDouble to pass to a C function.

In the past, when I've asked how to do this, I'm told: realToFrac. This
works in most cases, but recently gave me a problem that took me *forever* 
to track down:

Prelude Foreign.C> (0 :: CDouble) / 0
NaN
Prelude Foreign.C> (0 :: Double) / 0
NaN
Prelude Foreign.C> realToFrac ((0 :: Double) / 0) :: CDouble
-Infinity



yikes!  the NaN got turned into a -Infinity!!!

aside from manually checking for 'strange' Double/CDouble values and 
wrapping realToFrac, is there a better way?  also, does this count as a 
bug?

-- 
 Hal Daume III                                   | [EMAIL PROTECTED]
 "Arrest this man, he talks in maths."           | www.isi.edu/~hdaume

_______________________________________________
Glasgow-haskell-users mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users

Reply via email to