export interface ScientificNotationParts {
  base: string;
  exponent: string;
}

const SCIENTIFIC_REGEX = /^([+-]?\d+(?:\.\d+)?)(?:[eE]([+-]?\d+))$/;

export function parseScientificNotation(value: string): ScientificNotationParts | null {
  const match = SCIENTIFIC_REGEX.exec(value);
  if (!match) {
    return null;
  }
  const exponent = match[2].replace(/^\+/, '') || '0';
  return {
    base: match[1],
    exponent,
  };
}
