You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Jubilee (Jira)" <ji...@apache.org> on 2020/10/29 17:03:00 UTC

[jira] [Created] (GROOVY-9797) println(-0.0f) does not comply with IEEE754

Jubilee created GROOVY-9797:
-------------------------------

             Summary: println(-0.0f) does not comply with IEEE754
                 Key: GROOVY-9797
                 URL: https://issues.apache.org/jira/browse/GROOVY-9797
             Project: Groovy
          Issue Type: Bug
          Components: Groovysh
    Affects Versions: 3.0.6, 2.5.13, 2.4.17, 2.5.7
         Environment: Linux
            Reporter: Jubilee


IEEE754-2019 (which supersedes all previous floating point standards for decimal or binary floating point) states that an implementation *shall* (that means "is required to") preserve the sign on floating point numbers when it converts numbers to an "external decimal character sequence" (that means "prints them the way everyone does, unless you use special formatting characters I guess"), singling out the two zeros and the two infinities in particular for this treatment.

 

IEEE754-2019 does not say this for no reason. It's because conformant floating point implementations can print the float out and then later read it back into its original floating point bit-pattern. A close reading of IEEE754-1985 suggests this was always the intention, but this requirement was made unambiguously explicit for signed zeros as early as IEEE854-1987.

 

On all the versions of Apache Groovy's REPL that I was able to trivially easily test, println(-0.0f) does not output "-0.0", but outputs "0.0" instead.  While I am aware that printf is also available in Groovy and can allow one to select formatting, this should probably be considered a bug, especially given that println in Java (OpenJDK 14) outputs "-0.0" and so do Kotlin, Scala, and Clojure with their relevant commands.

 

This bug suggests there are other errors relevant to IEEE754 compliance in relevant formatting and parsing code, so it is a good idea to do a more thorough audit as well.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)