Results for “floating”
Small, practical examples. Search by task or narrow things down below.
Round halfway floating-point values away from zero
C++: std::round has an explicit halfway rule different from truncation.
C++✓ Tested
Validate a complete floating-point input
C: strtod exposes both the stopping position and range errors; reject nonfinite results when required.
C✓ Tested
Calculate whole days between dates
Subtract Julian day values for date-only inputs.
julianday✓ Tested
Calculate with exact rational values
Python: Use Fraction for exact ratios rather than binary floating-point approximations.
Python✓ Tested
Convert Celsius to Fahrenheit
Arduino / C: Use floating-point constants to avoid integer division.
Arduino / C✓ Tested
Divide using a fractional number
Python: Use a floating-point operand to preserve the fractional part of a division.
Python✓ Tested
Divide using a fractional number
C#: Use a floating-point operand to preserve the fractional part of a division.
C#✓ Tested
Divide using a fractional number
Java: Use a floating-point operand to preserve the fractional part of a division.
Java✓ Tested
Divide using a fractional number
JavaScript: Use a floating-point operand to preserve the fractional part of a division.
JavaScript✓ Tested
Divide using a fractional number
TypeScript: Use a floating-point operand to preserve the fractional part of a division.
TypeScript✓ Tested
Divide using a fractional number
C++: Use a floating-point operand to preserve the fractional part of a division.
C++✓ Tested
Divide using a fractional number
C: Use a floating-point operand to preserve the fractional part of a division.
C✓ Tested