Skip to content
Tcl Source Code Artifact [31fcc7f7d3]
Login

Artifact [31fcc7f7d3]

Artifact 31fcc7f7d38d64487e639fa8bbb4f0a52667091e:

Ticket change [31fcc7f7d3] - Ticket [3105247fffffffff|3105247fff] <i>-NaN?</i> status still Open with 4 other changes by nijtmans on 2010-11-10 16:46:15.
D 2010-11-10T16:46:15
J icomment OK,\sI'll\sexplain\swhy\sI\sthink\sthat\sChristoph\sis\sright.\n\nThe\srelevant\sTIP\shere\sis\n\sTIP\s#249:\sUnification\sof\sTcl's\sParsing\sof\sNumbers\n\nThe\simplentation\scame\sfrom\sthe\skennykb-numerics-branch,\swhich\scame\nwith\sTcl\s8.5:\n2005-05-10\s\sKevin\sKenny\s\s<[email protected]>\nMerged\sall\schanges\son\skennykb-numerics-branch\sback\sinto\sthe\sHEAD.\nTIP's\s132\sand\s232\sare\snow\sFinal.\n\nThis\sTIP\s#249\sstates:\n\s8.\sThe\sconstants,\s"Inf",\sand\s"Infinity"\s(perhaps\swith\sa\sleading\ssignum)\sare\sinterpreted\nas\sinfinities.\sInfinity\sis\srepresented\sas\stclDoubleType.\n\s9.\sThe\sconstant\s"NaN"\sis\sthe\sIEEE\s"Not\sa\sNumber"\svalue.\sIt\sis\sspecifically\npermitted\sin\sthe\sparser\sso\sthat\sbinary\sformat\sq\sNaN\sand\ssimilar\scalls\ncan\sproduce\sNaN\son\san\sexternal\smedium.\sThe\spresence\sof\sNaN\sin\sexpressions,\nor\sin\sTcl_GetDoubleFromObj,\ssignals\san\serror.\sNaN\sis\srepresented\sas\stclDoubleType.\n10.\sIEEE\sfloating\spoint\sdoes\snot\shave\sa\ssingle\sunique\sNaN\svalue,\sso\sa\sNaN\smay\sbe\naugmented\sby\sa\sparenthesized\sstring\sof\shexadecimal\sdigits,\swhich\swill\sbe\sstored\nin\sits\sleast\ssignificant\sbits.\sIt\sshall\snot\sbe\spossible\sto\sconstruct\ssignalling\nNaN\sby\sthis\sroute;\sonly\squiet\sNaN\swill\sbe\ssupported.\sNaN\sis\srepresented\sas\stclDoubleType.\n\n\nNothing\swrong\shere,\sexcept\sthat\snowhere\sis\smentioned\sthat\sNaN's\smay\sbe\snegative\sas\swell\sas\sInf.\sThe\nonly\splace\sit\scan\sbe\sderived\sthat\sNaN's\smay\sbe\snegative\sis\sthe\sstate\sdiagram,\sbut\sI\swould\nargue\sthat\sin\sthis\srespect,\sthe\sstate\sdiagram\sdoes\snot\smatch\sthe\stext.\n\nHow\sdoes\slibc\sit?\sSome\sC-code:\ndouble\sd;\nmemcpy(&d,\s"\\000\\000\\000\\000\\000\\000\\370\\177",\s8);\nprintf("%g\\n",\sd);\nmemcpy(&d,\s"\\000\\000\\000\\000\\000\\000\\370\\377",\s8);\nprintf("%g\\n",\sd);\nmemcpy(&d,\s"\\001\\000\\000\\000\\000\\000\\370\\177",\s8);\nprintf("%g\\n",\sd);\nmemcpy(&d,\s"\\001\\000\\000\\000\\000\\000\\370\\377",\s8);\nprintf("%g\\n",\sd);\nOn\sWindows\sXP\s(mingw),\sthis\sprints:\n1.#QNAN\n-1.#QNAN\n1.#QNAN\n-1.#QNAN\nOn\sLinux\s(Ubuntu\s10.4,\sAMD64)\nnan\n-nan\nnan\n-nan\nIn\sJava\nDouble\sd\s=\sDouble.longBitsToDouble(0x7ff8000000000000L);\n\s\s\s\s\s\s\s\sSystem.out.println(d);\nd\s=\sDouble.longBitsToDouble(0xfff8000000000000L);\n\s\s\s\s\s\s\s\sSystem.out.println(d);\nd\s=\sDouble.longBitsToDouble(0x7ff8000000000001L);\n\s\s\s\s\s\s\s\sSystem.out.println(d);\nd\s=\sDouble.longBitsToDouble(0xfff8000000000001L);\n\s\s\s\s\s\s\s\sSystem.out.println(d);\nThis\sprints\nNaN\nNaN\nNaN\nNaN\n\n\nSo,\swhat\sshould\swe\sfollow?\sThe\sC\sway,\swhich\sis\snon-portable\s(as\sin\sTcl\s8.4).\sOr\nthe\sJava\sway,\swhich\sdoesn't\shave\sa\s-NaN?\sCurrently\swe\suse\sa\smixture,\swhich\sis\snot\nwell\sdescribed\sin\sTIP\s#249\n\nMore\sopinions?\n
J login nijtmans
J mimetype text/plain
J username nijtmans
K 3105247fffffffffffffffffffffffffffffffff
U nijtmans
Z 51969710b2783e0762de9cfc18f5c8b3