Floating-Point Types
Floating-point types are used to represent numbers with fractional parts, including Float16, Float32, and Float64, corresponding to IEEE 754 half-precision, single-precision, and double-precision formats respectively. Float64 is the default floating-point type, with approximately 15 significant digits of precision.
Floating-point literals support both decimal and hexadecimal forms. Decimal literals must include either an integer part or a fractional part, and can use e or E to indicate an exponent (base 10). Hexadecimal literals start with 0x and must include an exponent prefixed with p or P (base 2).
You can explicitly specify the type using suffixes: f16, f32, and f64 correspond to the three floating-point types. The code on the right demonstrates floating-point operations and different representation styles.
++ and decrement -- operators, unlike integer types.Try modifying the distance and time values to see how the speed calculation changes.