Skip to content

How to get consistent scientific notation with limited precision in Bigloo Scheme? #135

@gurpreetsinghhry

Description

@gurpreetsinghhry

I'm working with floating-point numbers in Bigloo Scheme, and I encountered a precision issue when performing a simple multiplication:

(* 0.005 1e-9)
;; => 5.0000000000000005e-12
I was expecting the result to be:

5.0e-12
I understand this is due to floating-point imprecision (IEEE 754), but I want to format the output to match what I logically expect—i.e., scientific notation with limited significant digits (e.g., 1 or 2 decimal places after the leading digit).

Expectations:
Output should be as clean as possible, ideally matching how other languages print such numbers (e.g., 5e-12 or 5.0e-12)
I do not want full-precision output like 5.0000000000000005e-12

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions