Pure Programmer
Blue Matrix


Cluster Map

Project: Floating Point Underflow

Write a program to print the positive floating point value closest to 0 that is possible to represent accurately with [[IEEE doubles]]. Also print a value slightly closer to show that it becomes 0. Does the language produce an error or simply a warning on underflow?

Output
$ rustc FloatingPointUnderflow.rs warning: variable `smallFloat` should have a snake case name --> FloatingPointUnderflow.rs:8:10 | 8 | let mut smallFloat:f64 = 1e-308f64; | ^^^^^^^^^^ help: convert the identifier to snake case: `small_float` | = note: `#[warn(non_snake_case)]` on by default warning: 1 warning emitted $ ./FloatingPointUnderflow Small float: 0.00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001 Smaller float: 0.00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001 Smallest float: 0

Solution