// Format large numbers for display export const formatNumber = (num: number): string => { if (num === 0) return '0'; const suffixes = ['', 'K', 'M', 'B', 'T', 'Qa', 'Qi', 'Sx', 'Sp', 'Oc', 'No', 'Dc']; // For very small numbers, just return the number if (num < 1) return num.toFixed(2); // For numbers less than 1000, show them as is if (num < 1000) return num.toFixed(0); // Find the suffix index const suffixIndex = Math.floor(Math.log10(num) / 3); if (suffixIndex >= suffixes.length) { // For extremely large numbers, use scientific notation return num.toExponential(2); } // Format with the appropriate suffix const scaledNum = num / Math.pow(10, suffixIndex * 3); // For numbers like 1000-9999, show one decimal place // For larger numbers, show two decimal places const decimalPlaces = scaledNum < 10 ? 1 : 0; return scaledNum.toFixed(decimalPlaces) + suffixes[suffixIndex]; };