Skip to content

Real.fromString on negative inf/infinity returns positive infinity #362

Closed

Description

@shwestrick

Version

110.99.8 (Latest)

Operating System

  • Any
  • Linux
  • macOS
  • Windows
  • Other Unix

OS Version

Sequoia 15.5

Processor

  • Any
  • Arm (using Rosetta)
  • PowerPC
  • Sparc
  • x86 (32-bit)
  • x86-64 (64-bit)
  • Other

System Component

Basis Library

Severity

Minor

Description

Real.fromString "-inf" returns SOME inf, i.e., positive infinity. It appears to only be a problem with inf/infinity parsing (e.g., in the the -nan case we get a negative sign bit).

Transcript

Testing a few combinations of [~-](inf|infinity); all of these return positive inf.

Standard ML of New Jersey [Version 110.99.8; 64-bit; April 25, 2025]
- 
- fun test x = Real.== (Real.posInf, valOf (Real.fromString x));
val test = fn : string -> bool
- 
- test "-inf"; test "~inf"; test "-infinity"; test "~infinity";
val it = true : bool
val it = true : bool
val it = true : bool
val it = true : bool

Confirming that negative nan is parsing correctly:

- Real.fromString "-nan"; Real.signBit (valOf it);
val it = SOME nan : real option
val it = true : bool
-
- Real.fromString "nan"; Real.signBit (valOf it);
val it = SOME nan : real option
val it = false : bool

Expected Behavior

Real.fromString on "-inf" and similar inputs should return SOME (~inf).

Steps to Reproduce

Please see transcript above.

Additional Information

No response

Email address

<github username> at gmail

Activity

  1. added
    basis-libproblem with Standard ML Basis library
    floating-pointproblem related to floating-point operations
    on Jun 12, 2025
  2. self-assigned this
    on Jun 12, 2025
  3. added a commit that references this issue on Jun 12, 2025
  4. JohnReppy commented on Jun 12, 2025

    @JohnReppy
    Contributor

    This issue was caused by a copy-paste error for the bit-representation of negative infinity. It has been fixed for 110.99.9.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

basis-libproblem with Standard ML Basis librarybugSomething isn't workingfixed-in-110.99.9issues fixed in the 110.99.9 releasefloating-pointproblem related to floating-point operations

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions