char-fork/llama.cpp
git clone https://git.t4t.associates/char-fork/llama.cpp
59778f019
char/aliceai-t5-moe
1/** 2* Floating-point precision utilities 3* 4* Provides functions to normalize floating-point numbers for consistent comparison 5* and display, addressing JavaScript's floating-point precision issues. 6*/ 7 8import { PRECISION_MULTIPLIER } from '$lib/constants' ; 9 10/** 11* Normalize floating-point numbers for consistent comparison 12* Addresses JavaScript floating-point precision issues (e.g., 0.949999988079071 → 0.95) 13*/ 14export function normalizeFloatingPoint ( value :unknown ) :unknown { 15return typeof value === 'number' 16 ?Math . round ( value * PRECISION_MULTIPLIER ) / PRECISION_MULTIPLIER 17 :value ; 18} 19 20/** 21* Type-safe version that only accepts numbers 22*/ 23export function normalizeNumber ( value :number ) :number { 24return Math . round ( value * PRECISION_MULTIPLIER ) / PRECISION_MULTIPLIER ; 25}