Josef Templ wrote:Is there anything else required for supporting negative zero?
For example: conversion to/from string or parsing a constant like -0.0 in the compiler.
An interesting question.
1 - Around about BlackBox 1.2 the compiler did have problems with the constant -0.0. I drew this to Oms's attention, and it was fixed. I am unaware of any other compiler issues.
2 - There are (many!) compiler issues with NaNs, but that is a different, and harder, issue.
3 - Conversion to string. My formatter (LibFmtrs) has the option to display the sign of zero (it has several other REAL number formatting options). It does this by post-processing the string returned from the standard Strings library module. So I have no need to consider changes here.
4 - Conversion from string. Don't think any changes are required. Both the compiler and the Strings module can read -0.0 correctly.
(I have a private hack in Strings that allows the unicode minus (−) sign to be used as well as the ASCII hyphen sign (-). In many fonts the unicode minus looks much better. This does not affect the compiler, which still rejects unicode minus − when it expects -.)
5 - I will have more to say about module Math and -0.0. In the table below the value of ArcSinh(-0.) looks suspicious. Can anyone test this value in other respectable libraries, such as C# or Java, and let me know what they do? (An easy way to test the sign of zero is to print 1 / x; 0.0 -> INF, -0.0 -> -INF).
Code: Select all
System.Math: ArcSinh & ArcTan ...
x ArcSinh (x) ArcTan (x)
−∞ −∞ −1.570796327
−500. −6.907756279 −1.568796329
−50. −4.605270171 −1.550798993
−5. −2.312438341 −1.373400767
−1. −0.881373587 −0.785398163
−0.5 −0.481211825 −0.463647609
−0. 0. −0.
0. 0. 0.
0.5 0.481211825 0.463647609
1. 0.881373587 0.785398163
5. 2.312438341 1.373400767
50. 4.605270171 1.550798993
500. 6.907756279 1.568796329
∞ ∞ 1.570796327