Skip to main content

java_format_double

Function java_format_double 

Source
pub fn java_format_double(v: f64) -> String
Expand description

Java Double.toString() compatible formatting.

This module provides java_format_double which produces output matching Java’s Double.toString(double) for the value ranges encountered in FastQC output. This is critical for byte-exact output matching. Format an f64 value to match Java’s Double.toString(double) output.

JAVA COMPAT: Java.s Double.toString always includes at least one digit after the decimal point (e.g., “9.0” not “9”), uses “NaN” (capital N-a-N), and switches to scientific notation with uppercase “E” for very large/small values.

Key differences from Rust’s default Display:

  • Rust prints 9 for 9.0f64; Java prints “9.0”
  • Rust prints NaN; Java prints “NaN” (same, fortunately)
  • Rust prints inf; Java prints “Infinity”
  • Rust prints -inf; Java prints “-Infinity”