<?xml version="1.0" encoding="ISO-8859-1"?>

<!DOCTYPE message PUBLIC
  "-//MLarc//DTD MLarc output files//EN"
  "../../mlarc.dtd"[
  <!ATTLIST message
    listname CDATA #REQUIRED
    title CDATA #REQUIRED
  >
]>

  <?xml-stylesheet href="../../mlarc.xsl" type="text/xsl"?>


<message 
  url="2003/10/c1eb0f38b646fdaf599a7528eb9c4ee6"
  from="Damien Doligez &lt;damien.doligez@i...&gt;"
  author="Damien Doligez"
  date="2003-10-16T22:52:06"
  subject="Re: [Caml-list] Weird behavior with nan&apos;s and min/max"
  prev="2003/10/dc6b874ec397bff1e2016e7a813019ca"
  next="2003/10/71219d18280cf90894b34e1a9fcc1689"
  prev-in-thread="2003/10/dc6b874ec397bff1e2016e7a813019ca"
  next-in-thread="2003/10/84ed68a791de5fdc1f6098100bd856e4"
  prev-thread="2003/10/bb6652d3ee0174ff91bc648fa5125d46"
  next-thread="2003/10/6638aad0140dc99b2349c854da4948c3"
  root="../../"
  period="month"
  listname="caml-list"
  title="Archives of the Caml mailing list">

<thread subject="[Caml-list] Weird behavior with nan&apos;s and min/max">
<msg 
  url="2003/10/686468535e6100213e2e85bca8be51f1"
  from="Yaron Minsky &lt;yminsky@c...&gt;"
  author="Yaron Minsky"
  date="2003-10-14T14:37:18"
  subject="[Caml-list] Weird behavior with nan&apos;s and min/max">
<msg 
  url="2003/10/3133ffc353d5d33e5386f5e4c73b858f"
  from="Yaron Minsky &lt;yminsky@c...&gt;"
  author="Yaron Minsky"
  date="2003-10-14T14:56:56"
  subject="Re: [Caml-list] Weird behavior with nan&apos;s and min/max">
<msg 
  url="2003/10/48561de698e6c05397123c5888cc4dc1"
  from="Yaron Minsky &lt;yminsky@c...&gt;"
  author="Yaron Minsky"
  date="2003-10-14T20:52:17"
  subject="Re: [Caml-list] Weird behavior with nan&apos;s and min/max">
<msg 
  url="2003/10/22b8f0ac4fb38072f78facd4bf9434a7"
  from="skaller &lt;skaller@o...&gt;"
  author="skaller"
  date="2003-10-14T23:45:32"
  subject="Re: [Caml-list] Weird behavior with nan&apos;s and min/max">
<msg 
  url="2003/10/242867c4c7ffbfa1014a17fb343b34a9"
  from="Hendrik Tews &lt;tews@t...&gt;"
  author="Hendrik Tews"
  date="2003-10-16T17:29:55"
  subject="Re: [Caml-list] Weird behavior with nan&apos;s and min/max">
</msg>
</msg>
</msg>
</msg>
<msg 
  url="2003/10/0b43b6a621394f9ecc76084111d3253d"
  from="Xavier Leroy &lt;xavier.leroy@i...&gt;"
  author="Xavier Leroy"
  date="2003-10-16T13:17:07"
  subject="Re: [Caml-list] Weird behavior with nan&apos;s and min/max">
<msg 
  url="2003/10/896e4961fd3e3f4a71d469b298ebc60e"
  from="Yaron Minsky &lt;yminsky@c...&gt;"
  author="Yaron Minsky"
  date="2003-10-16T14:01:29"
  subject="Re: [Caml-list] Weird behavior with nan&apos;s and min/max">
<msg 
  url="2003/10/0eef11bc0ed3dcaefa1de6d2feea29a3"
  from="Christophe TROESTLER &lt;debian00@t...&gt;"
  author="Christophe TROESTLER"
  date="2003-10-17T09:25:50"
  subject="[Caml-list] Test nan (was: Weird behavior with nan&apos;s and min/max)">
</msg>
</msg>
<msg 
  url="2003/10/a832440f4488e9cf40654b2ad77a5c76"
  from="Yaron Minsky &lt;yminsky@c...&gt;"
  author="Yaron Minsky"
  date="2003-10-16T21:40:46"
  subject="Re: [Caml-list] Weird behavior with nan&apos;s and min/max">
<msg 
  url="2003/10/dc6b874ec397bff1e2016e7a813019ca"
  from="Yaron Minsky &lt;yminsky@c...&gt;"
  author="Yaron Minsky"
  date="2003-10-16T21:50:35"
  subject="Re: [Caml-list] Weird behavior with nan&apos;s and min/max">
</msg>
<msg 
  url="2003/10/c1eb0f38b646fdaf599a7528eb9c4ee6"
  from="Damien Doligez &lt;damien.doligez@i...&gt;"
  author="Damien Doligez"
  date="2003-10-16T22:52:06"
  subject="Re: [Caml-list] Weird behavior with nan&apos;s and min/max">
</msg>
</msg>
<msg 
  url="2003/10/84ed68a791de5fdc1f6098100bd856e4"
  from="skaller &lt;skaller@o...&gt;"
  author="skaller"
  date="2003-10-17T14:56:33"
  subject="Re: [Caml-list] Weird behavior with nan&apos;s and min/max">
<msg 
  url="2003/10/dd582ea4978aa94ec44762de52be023d"
  from="Yaron Minsky &lt;yminsky@c...&gt;"
  author="Yaron Minsky"
  date="2003-10-17T15:14:06"
  subject="Floating point exceptions (Was Re: [Caml-list] Weird behavior with  nan&apos;s and min/max)">
</msg>
<msg 
  url="2003/10/2547e7d7d785deed112b4caad2e8f5c2"
  from="Yaron M. Minsky &lt;yminsky@c...&gt;"
  author="Yaron M. Minsky"
  date="2003-10-17T23:56:05"
  subject="Re: [Caml-list] Weird behavior with nan&apos;s and min/max">
<msg 
  url="2003/10/ef4a5558eeba1a0b9901b9af7a62d4cf"
  from="Xavier Leroy &lt;xavier.leroy@i...&gt;"
  author="Xavier Leroy"
  date="2003-10-20T13:29:23"
  subject="Re: [Caml-list] Weird behavior with nan&apos;s and min/max">
<msg 
  url="2003/10/ae21027a037cf89c74ed354226a8cb16"
  from="Yaron Minsky &lt;yminsky@c...&gt;"
  author="Yaron Minsky"
  date="2003-10-20T13:43:13"
  subject="Re: [Caml-list] Weird behavior with nan&apos;s and min/max">
<msg 
  url="2003/10/3ed5948ec142822cf10a8e406fdc428b"
  from="Xavier Leroy &lt;xavier.leroy@i...&gt;"
  author="Xavier Leroy"
  date="2003-10-20T14:24:47"
  subject="Re: [Caml-list] Weird behavior with nan&apos;s and min/max">
</msg>
</msg>
</msg>
</msg>
</msg>
</msg>
<msg 
  url="2003/10/84b26be77ae760b6c6d2291d12cde704"
  from="Jed Davis &lt;jdev@p...&gt;"
  author="Jed Davis"
  date="2003-10-17T15:54:27"
  subject="[Caml-list] Re: Weird behavior with nan&apos;s and min/max">
</msg>
</msg>
</thread>

<contents>
On Thursday, October 16, 2003, at 11:40 PM, Yaron Minsky wrote:

&gt; let is_obj_nan x =
&gt;   Obj.tag (Obj.repr x) = Obj.double_tag &amp;&amp;
&gt;   (let f = (Obj.magic x : float) in not (f = f))
[...]
&gt; The resulting code segfaulted on me, and the segfault went away when I
&gt; went back to the ordinary min and max.  Does anyone have a thought on
&gt; this?  Is this use of Obj safe or not?

The problem is that the argument of Obj.tag must be a pointer value
that lives in the heap.  A pointer value answers false to Obj.is_int,
but you have no way to test for heap-allocated values.

This is going to change soon because I am fixing the bug found by
Jacques with float lazy arrays, and in the process I will extend
Obj.tag to give meaningful answers for ints and non-heap-allocated
values.

In the meantime, you can use the following code, but it might still
fail in some rare cases when applied to non-heap-allocated values
(I/O channels for example):

let is_obj_nan x =
   not (Obj.is_int (Obj.repr x)) &amp;&amp;
   Obj.tag (Obj.repr x) = Obj.double_tag &amp;&amp;
   (let f = (Obj.magic x : float) in not (f = f))
;;

-- Damien

-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners

</contents>

</message>

