Pure Programmer
Blue Matrix


Cluster Map

Project: Floating Point Overflow

Write a program to print the largest positive floating point value that is possible to represent accurately with [[IEEE doubles]]. Also print a value slightly larger to show what happens on overflow. Does the language produce an error or simply a warning on overflow?

Output
$ rustc FloatingPointOverflow.rs error[E0610]: `{integer}` is a primitive type and therefore doesn't have fields --> FloatingPointOverflow.rs:10:18 | 10 | largeFloat *= 2.f64; | ^^^ | help: if intended to be a floating point literal, consider adding a `0` after the period | 10 | largeFloat *= 2.0f64; | + error[E0610]: `{integer}` is a primitive type and therefore doesn't have fields --> FloatingPointOverflow.rs:12:18 | 12 | largeFloat *= 2.f64; | ^^^ | help: if intended to be a floating point literal, consider adding a `0` after the period | 12 | largeFloat *= 2.0f64; | + error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0610`.

Solution