Download tools/server/webui/src/lib/utils/precision.ts from OpenTransformer/llama.cpp-prismml: direct link, hf CLI and curl.
- Browser
- Download file 803 Bytes
-
https://huggingface.co/OpenTransformer/llama.cpp-prismml/resolve/main/tools/server/webui/src/lib/utils/precision.ts
- Command line
-
hf download hf://OpenTransformer/llama.cpp-prismml/tools/server/webui/src/lib/utils/precision.ts
-
curl -L -o precision.ts https://huggingface.co/OpenTransformer/llama.cpp-prismml/resolve/main/tools/server/webui/src/lib/utils/precision.ts
803 Bytes
| /** | |
| * 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/precision'; | |
| /** | |
| * 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; | |
| } | |