Version française
Home     About     Download     Resources     Contact us    
Browse thread
int_of_string bug
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Markus Mottl <markus.mottl@g...>
Subject: Re: [Caml-list] int_of_string bug
On 3/30/07, Erik de Castro Lopo <mle+ocaml@mega-nerd.com> wrote:
> But 64 bit systems get it right.

Not really:

# int_of_string "4611686018427387903";;
- : int = 4611686018427387903
# int_of_string "4611686018427387904";;
- : int = -4611686018427387904
# int_of_string "4611686018427387905";;
Exception: Failure "int_of_string".

The problem is just shifted to bigger numbers.  This problem arises
with all integer conversion functions, i.e. Int64.of_string,
Int32.of_string, Nativeint.of_string, int_of_string.

Regards
Markus

-- 
Markus Mottl        http://www.ocaml.info        markus.mottl@gmail.com