Revert "Improve scientific notation formatting"

This reverts commit ca7632bf25.
This commit is contained in:
Codex Agent
2026-03-08 18:41:14 +00:00
parent cf0b72269c
commit f315ff1dc1
5 changed files with 23 additions and 81 deletions

View File

@@ -1,19 +1,20 @@
<script lang="ts">
import { solve } from '$lib/engine';
import ScientificNotationValue from '$lib/components/ScientificNotationValue.svelte';
import { parseScientificNotation, type ScientificNotationParts } from '$lib/utils/formatScientific';
import type { CalculatorDef } from '$lib/data/calculators';
export let config: CalculatorDef;
const numericSamples = [0.1, 0.5, 1, 2, 5, 10, 20, 50, 100];
type Row = { input: number; output: string };
type Row = { input: number; output: string; scientific?: ScientificNotationParts };
const buildRow = (value: number): Row => {
const formatted = solve(config, 1, value.toString(), '', '');
return {
input: value,
output: formatted.val2 || '—',
scientific: formatted.val2 ? parseScientificNotation(formatted.val2) ?? undefined : undefined,
};
};
@@ -44,7 +45,14 @@
<p class="chart-statement">
Converting {row.input} <span class="chart-unit">{inputLabel}</span> into <span class="chart-unit">{outputLabel}</span> equals
<span class="chart-output-value">
<ScientificNotationValue value={row.output} fallback="—" />
{#if row.scientific}
<span class="scientific-base">{row.scientific.base}</span>
<span class="scientific-suffix">
×10<sup>{row.scientific.exponent}</sup>
</span>
{:else}
{row.output}
{/if}
</span>
<span class="chart-output-unit">{outputLabel}</span>.
</p>