small fixes
This commit is contained in:
@@ -5,6 +5,7 @@ import { Card } from "@/components/ui/card";
|
||||
import { StepControls } from "./step-controls";
|
||||
import { MathDisplay } from "@/components/math/math-display";
|
||||
import { simplify, toKatex, gcd } from "@/lib/math/fractions";
|
||||
import { parseStrictDecimal, parseStrictInt } from "@/lib/math/validation";
|
||||
|
||||
type ConvertMode = "decToFrac" | "fracToDec";
|
||||
|
||||
@@ -161,16 +162,16 @@ export function ConversionExplorer() {
|
||||
try {
|
||||
let s: Step[];
|
||||
if (mode === "decToFrac") {
|
||||
const val = parseFloat(decInput);
|
||||
if (isNaN(val) || val < 0 || val >= 10) {
|
||||
const val = parseStrictDecimal(decInput);
|
||||
if (val === null || val < 0 || val >= 10) {
|
||||
setError("Enter a valid decimal between 0 and 10.");
|
||||
return;
|
||||
}
|
||||
s = buildDecToFracSteps(decInput.trim());
|
||||
} else {
|
||||
const n = parseInt(numInput);
|
||||
const d = parseInt(denInput);
|
||||
if (isNaN(n) || isNaN(d) || d === 0) {
|
||||
const n = parseStrictInt(numInput);
|
||||
const d = parseStrictInt(denInput);
|
||||
if (n === null || d === null || d === 0) {
|
||||
setError("Enter a valid fraction (denominator ≠ 0).");
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user