Class FixedPointMath
- Namespace
- DocWright.Core.Primitives
- Assembly
- DocWright.Core.dll
Integer fixed-point arithmetic helpers used by all layout math.
public static class FixedPointMath
- Inheritance
-
FixedPointMath
- Inherited Members
Remarks
All DocWright layout arithmetic is integer twip arithmetic; floating point is only permitted inside font table parsing and at the renderer output boundary. Rounding is always round-half-away-from-zero, which matches Word's observed behavior when it converts font design units to twips (see the Microsoft OpenType specification for funit scaling: value * pointSize * 20 / unitsPerEm).
All operations are checked: an overflow throws OverflowException rather than silently wrapping, so corrupt documents cannot produce garbage geometry.
Methods
- DivRound(long, long)
Divides two 64-bit integers, rounding the quotient half away from zero.
- MulDivRound(long, long, long)
Computes
value * multiplier / divisorentirely in 64-bit integer arithmetic, rounding the quotient half away from zero.
- MulDivRound32(int, int, int)
Computes
value * multiplier / divisorin integer arithmetic with round-half-away-from-zero, returning a 32-bit result.
- RoundHalfAwayFromZero(double)
Rounds a floating-point value to the nearest 32-bit integer, rounding midpoints away from zero (0.5 becomes 1, -0.5 becomes -1).
- RoundHalfAwayFromZeroToInt64(double)
Rounds a floating-point value to the nearest 64-bit integer, rounding midpoints away from zero.