@mocanvas/editor · function

isSafeFloat

declare function isSafeFloat(n: unknown): boolean

Whether n is a number a geometry routine may safely divide by, compare or persist: finite, not NaN, and inside the range where a double still has enough mantissa left to be meaningful at canvas scale.

SEMANTICS-ASSUMED: the bound. The docs name the predicate but not its threshold, so it is derived from what the check is *for* — a page coordinate beyond Number.MAX_SAFE_INTEGER can no longer represent its own integer part exactly, at which point snapping, hit testing and bounds arithmetic all stop agreeing with each other. A shape that far out is a corrupt record, not a distant one.

mocanvas is built by Symbio. Free for non-commercial, non-profit and development use; commercial use needs an agreement. Not affiliated with or endorsed by tldraw.