Sisu
E0104

Integer literal not exactly an f64

ErrorSafe fix

Built from the repository at commit a8614dc.

An integer literal in a place that expects an f64 must be a value the f64 holds exactly. Every integer up to 2^53 (9007199254740992) is one; above that, only some are.

Why

An f64 has 53 bits of precision, so above 2^53 it skips integers. 9007199254740993 would become 9007199254740992.0, a different number, and Sisu does not change a number silently. The fix writes the value the f64 holds, as a float literal, so the program says what it computes.

Broken

fn main() {
    let x: f64 = 9007199254740993
    print(x)
}

What sisu says

error[E0104]: `9007199254740993` is not exactly an `f64`
 --> E0104.sisu:2:18
  |
2 |     let x: f64 = 9007199254740993
  |                  ^^^^^^^^^^^^^^^^
  |
help: write `9007199254740992.0`
  |
2 -     let x: f64 = 9007199254740993
2 +     let x: f64 = 9007199254740992.0
  |

sisu: 1 error
sisu: for more on a code, run `sisu explain <code>`: E0104

Fixed

fn main() {
    let x: f64 = 9007199254740992.0
    print(x)
}

Related

  • E0040: an integer literal too large for u8.