Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

Browse thread
[Caml-list] NaN-safe min and max
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2003-10-15 (14:52)
From: Yaron Minsky <yminsky@c...>
Subject: [Caml-list] NaN-safe min and max
Olivier Andrieu proposed the following code for doing a safe min/max. 
Does anyone have any thoughts about this code snippet, and whether it is
or is not a safe use of Obj.magic?

 let min a b =
    let o = Obj.repr a in
    if Obj.is_block o && Obj.tag o = Obj.double_tag
    then Obj.magic (fmin (Obj.magic a) (Obj.magic b))
    else Pervasives.min a b

To unsubscribe, mail Archives:
Bug reports: FAQ:
Beginner's list: