Buckets:
| /** | |
| * Floating-point precision utilities | |
| * | |
| * Provides functions to normalize floating-point numbers for consistent comparison | |
| * and display, addressing JavaScript's floating-point precision issues. | |
| */ | |
| import { PRECISION_MULTIPLIER } from '$lib/constants'; | |
| /** | |
| * Normalize floating-point numbers for consistent comparison | |
| * Addresses JavaScript floating-point precision issues (e.g., 0.949999988079071 → 0.95) | |
| */ | |
| export function normalizeFloatingPoint(value: unknown): unknown { | |
| return typeof value === 'number' | |
| ? Math.round(value * PRECISION_MULTIPLIER) / PRECISION_MULTIPLIER | |
| : value; | |
| } | |
| /** | |
| * Type-safe version that only accepts numbers | |
| */ | |
| export function normalizeNumber(value: number): number { | |
| return Math.round(value * PRECISION_MULTIPLIER) / PRECISION_MULTIPLIER; | |
| } | |
Xet Storage Details
- Size:
- 793 Bytes
- Xet hash:
- a64c7bdb907d445e75956de1335d5862734979096dc3bd600b7080af9ba28f7a
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.