export function formatConversionValue(value) {
  if (value === null || value === undefined || Number.isNaN(value)) {
    return '—';
  }
  if (!Number.isFinite(value)) {
    return value.toString();
  }
  if (value === 0) {
    return '0';
  }
  const rounded = parseFloat(value.toFixed(6));
  if (rounded !== 0) {
    return rounded.toString();
  }
  const precise = value.toFixed(12).replace(/\.?0+$/, '');
  if (precise !== '0' && precise !== '') {
    return precise;
  }

  // Fallback for extremely small values: use scientific notation but clean it up
  const scientific = value.toExponential();
  return scientific.replace(/\.?0+e/, 'e');
}
