export default function num2str(n: number) { const f = Math.round(n * 100) / 100; let s = f.toString(); const rs = s.indexOf('.'); if (rs < 0) { return `${s}.00`; } while (s.length <= rs + 2) { s += '0'; } return s; }
()=>{const [str, setstr] = useState('0.0');function num2str(n) {const f = Math.round(n * 100) / 100;let s = f.toString();const rs = s.indexOf('.');if (rs < 0) {return `${s}.00`;}while (s.length <= rs + 2) {s += '0';}return s;}return <><div><span>type number:</span> <input type='number' max={100.00} min={-2.99} onChange={(e)=>{const val = Number(e.target.value);setstr(num2str(val));}} /></div><div><h3>${str}</h3></div></>;}