Version française
Home     About     Download     Resources     Contact us    
Browse thread
Bug converting numbers?
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Markus Mottl <mottl@m...>
Subject: Bug converting numbers?
Hello - Bonjour!

I have encountered unexpected behaviour converting integers to floats:

# let x = 7.;;
val x : float = 7
# let y = float 7;;
val y : float = 7
# x == y;;
- : bool = false

The internal representation of "7." is obviously different to "float 7".
Is there some reason to it? This makes it hard to write things like:

if a_float == float (truncate a_float) ...

if one wants to check whether a float can actually be represented as
an integer...

français:
La représentation de "7." et évidemment differente de "float 7".
Est-ce qu'il y a une raison? C'est un problème si on veut verifier si un
"float" peut être représenté comme "int"...

Regards,
Markus Mottl

-- 
*  Markus Mottl              |  University of Economics and       *
*  Department of Applied     |  Business Administration           *
*  Computer Science          |  Vienna, Austria                   *
*  mottl@miss.wu-wien.ac.at  |  http://miss.wu-wien.ac.at/~mottl  *