diff --git a/packages/ui/src/utils/formatting.ts b/packages/ui/src/utils/formatting.ts index 3493a1a..ce43c22 100644 --- a/packages/ui/src/utils/formatting.ts +++ b/packages/ui/src/utils/formatting.ts @@ -2,7 +2,7 @@ import { intlFormat } from '@shadcn/ui/lib/date-fns'; export function formatBytes(bytes: number) { if (bytes === 0) return '0 B'; - const k = 1000, // or 1024 + const k = 1024, // or 1000 sizes = ['B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'], i = Math.floor(Math.log(bytes) / Math.log(k)); diff --git a/packages/ui/src/utils/unit-conversions.ts b/packages/ui/src/utils/unit-conversions.ts index cb5cbfd..b836e2e 100644 --- a/packages/ui/src/utils/unit-conversions.ts +++ b/packages/ui/src/utils/unit-conversions.ts @@ -11,13 +11,13 @@ export function unitConversion( case 'dollarsToCents': return evaluate(`${value} * 100`); case 'bitsToMb': - return evaluate(`${value} / 1000 / 1000`); + return evaluate(`${value} / 1024 / 1024`); case 'mbToBits': - return evaluate(`${value} * 1000 * 1000`); + return evaluate(`${value} * 1024 * 1024`); case 'bytesToGb': - return evaluate(`${value} / 1000 / 1000 / 1000`); + return evaluate(`${value} / 1024 / 1024 / 1024`); case 'gbToBytes': - return evaluate(`${value} * 1000 * 1000 * 1000`); + return evaluate(`${value} * 1024 * 1024 * 1024`); default: throw new Error('Invalid conversion type'); }