interplane.Get Omega
Read in your language

omega-mv

Omega: a language for verified programs, semantic identity and machine realization. Seed-born work and existing implementations have distinct provenance.

Brought by drakestapleton

branch main Branches Tags History

omega-mv / gpu / head-to-head / lib.om

849 lines · 16670 bytes Raw Blame History
1note SPDX-License-Identifier: Apache-2.0
2note gpu/head-to-head/lib.om: pure-Omega paired GPU benchmark comparator and verification harness.
3note Derived from gpu-head-to-head (paired A/B timing statistics, numerical parity gate with NaN/Inf
4note refusal, IQR non-overlap comparison, bandwidth GB/s, control-mutant verification, deterministic
5note PASS/FAIL/NOT_RUN verdict emission). Library unit: no om2 directive, no fn main.
6
7const H2H_VERDICT_PASS ulong 0
8const H2H_VERDICT_FAIL ulong 1
9const H2H_VERDICT_NOT_RUN ulong 2
10
11const H2H_REASON_OK ulong 0
12const H2H_REASON_NO_PAIRS ulong 1
13const H2H_REASON_NO_ELEMS ulong 2
14const H2H_REASON_BAD_TIMING ulong 3
15const H2H_REASON_PARITY_FAIL ulong 4
16const H2H_REASON_MUTANT_NOT_RUN ulong 5
17const H2H_REASON_MUTANT_ESCAPED ulong 6
18const H2H_REASON_BAD_TOL ulong 7
19
20const H2H_CALL_OVERLAPPING ulong 0
21const H2H_CALL_B_FASTER ulong 1
22const H2H_CALL_A_FASTER ulong 2
23
24const H2H_MAX_SAMPLES ulong 4096
25const H2H_MAX_ELEMS ulong 65536
26
27struct H2hTol atol f64 rtol f64 end
28struct H2hParity ok ulong elem_n ulong mismatches ulong nan_cnt ulong inf_cnt ulong max_abs f64 max_rel f64 end
29struct H2hStats ok ulong n ulong min_ns ulong q1_ns ulong med_ns f64 q3_ns ulong iqr_ns ulong p95_ns ulong max_ns ulong end
30struct H2hSummary verdict ulong reason ulong bytes_moved ulong speedup f64 bw_a_gbps f64 bw_b_gbps f64 iqr_call ulong parity_ok ulong mutant_checked ulong mutant_caught ulong end
31
32text h2h_t_pass "PASS"
33text h2h_t_fail "FAIL"
34text h2h_t_notrun "NOT_RUN"
35text h2h_t_verdict "VERDICT="
36text h2h_t_reason " REASON="
37text h2h_t_nl "\n"
38text h2h_t_arma "ARM_A "
39text h2h_t_armb "ARM_B "
40text h2h_t_n "n="
41text h2h_t_min " min_ns="
42text h2h_t_q1 " q1_ns="
43text h2h_t_med " median_ns="
44text h2h_t_q3 " q3_ns="
45text h2h_t_iqr " iqr_ns="
46text h2h_t_p95 " p95_ns="
47text h2h_t_max " max_ns="
48text h2h_t_cmp "COMPARE speedup="
49text h2h_t_bwa " bw_a_gbps="
50text h2h_t_bwb " bw_b_gbps="
51text h2h_t_call " iqr_call="
52text h2h_t_call_ov "OVERLAPPING"
53text h2h_t_call_bf "ARM_B_FASTER"
54text h2h_t_call_af "ARM_A_FASTER"
55text h2h_t_par "PARITY ok="
56text h2h_t_elems " elems="
57text h2h_t_mis " mismatches="
58text h2h_t_nan " nan="
59text h2h_t_inf " inf="
60text h2h_t_mabs " max_abs="
61text h2h_t_mrel " max_rel="
62text h2h_t_mut "MUTANT checked="
63text h2h_t_caught " caught="
64text h2h_t_nan_str "NaN"
65text h2h_t_inf_str "Inf"
66text h2h_t_ninf_str "-Inf"
67text h2h_t_minus "-"
68text h2h_t_dot "."
69text h2h_t_r_ok "ok"
70text h2h_t_r_nopairs "no_pairs"
71text h2h_t_r_noelems "no_elems"
72text h2h_t_r_badtime "bad_timing"
73text h2h_t_r_parfail "parity_failed"
74text h2h_t_r_mutnr "mutant_not_run"
75text h2h_t_r_mutesc "mutant_escaped"
76text h2h_t_r_badtol "bad_tolerance"
77
78fn h2h_write_all fd int buf view uchar * to bool
79n = len buf
80pos = ulong 0
81while lt pos n bound 65536
82k = write fd buf pos sub n pos
83if le k 0
84ret false
85end
86pos = add pos ulong k
87end
88ret true
89end
90
91fn h2h_write_u64 fd int v ulong to void
92digits = new uchar 24 0
93if eq v 0
94put digits 0 uchar 48
95ok0 = h2h_write_all fd part digits 0 1
96if ok0
97ret
98end
99ret
100end
101tmp = new uchar 24 0
102cnt = ulong 0
103x = v
104while gt x 0 bound 24
105d = rem x 10
106put tmp cnt uchar add 48 d
107cnt = add cnt 1
108x = div x 10
109end
110i = ulong 0
111while lt i cnt bound 24
112put digits i get tmp sub sub cnt 1 i
113i = add i 1
114end
115ok1 = h2h_write_all fd part digits 0 cnt
116if ok1
117ret
118end
119end
120
121fn h2h_f64_is_nan x f64 to bool
122bits = bitcast ulong x
123exp = and shr bits 52 0x7ff
124frac = and bits 0xfffffffffffff
125ret and eq exp 0x7ff ne frac 0
126end
127
128fn h2h_f64_is_inf x f64 to bool
129bits = bitcast ulong x
130exp = and shr bits 52 0x7ff
131frac = and bits 0xfffffffffffff
132ret and eq exp 0x7ff eq frac 0
133end
134
135fn h2h_f64_is_finite x f64 to bool
136bits = bitcast ulong x
137exp = and shr bits 52 0x7ff
138ret ne exp 0x7ff
139end
140
141fn h2h_f64_is_neg x f64 to bool
142bits = bitcast ulong x
143ret ne shr bits 63 0
144end
145
146fn h2h_write_f64_6 fd int x f64 to void
147if h2h_f64_is_nan x
148okn = h2h_write_all fd h2h_t_nan_str
149if okn
150ret
151end
152ret
153end
154if h2h_f64_is_inf x
155if h2h_f64_is_neg x
156okni = h2h_write_all fd h2h_t_ninf_str
157if okni
158ret
159end
160else
161okpi = h2h_write_all fd h2h_t_inf_str
162if okpi
163ret
164end
165end
166ret
167end
168val = x
169if lt val 0.0f64
170okm = h2h_write_all fd h2h_t_minus
171if okm
172val = neg val
173else
174val = neg val
175end
176end
177scaled = ulong add mul val 1000000.0f64 0.5f64
178whole = div scaled 1000000
179frac = rem scaled 1000000
180h2h_write_u64 fd whole
181okd = h2h_write_all fd h2h_t_dot
182fbuf = new uchar 6 48
183p = ulong 5
184remf = frac
185for k ulong 6
186d = rem remf 10
187put fbuf p uchar add 48 d
188remf = div remf 10
189if gt p 0
190p = sub p 1
191end
192end
193okf = h2h_write_all fd part fbuf 0 6
194if and okd okf
195ret
196end
197end
198
199fn h2h_tol_valid tol view H2hTol to bool
200a = get tol atol
201r = get tol rtol
202if not h2h_f64_is_finite a
203ret false
204end
205if not h2h_f64_is_finite r
206ret false
207end
208if lt a 0.0f64
209ret false
210end
211if lt r 0.0f64
212ret false
213end
214ret true
215end
216
217fn h2h_parity_step va f64 vb f64 tol view H2hTol res edit H2hParity to void
218bad_nf = false
219if h2h_f64_is_nan va
220put res nan_cnt add get res nan_cnt 1
221bad_nf = true
222end
223if h2h_f64_is_nan vb
224put res nan_cnt add get res nan_cnt 1
225bad_nf = true
226end
227if h2h_f64_is_inf va
228put res inf_cnt add get res inf_cnt 1
229bad_nf = true
230end
231if h2h_f64_is_inf vb
232put res inf_cnt add get res inf_cnt 1
233bad_nf = true
234end
235if bad_nf
236put res mismatches add get res mismatches 1
237ret
238end
239diff = fabs sub va vb
240scale = fmax fabs va fabs vb
241rel = 0.0f64
242if gt scale 0.0f64
243rel = div diff scale
244end
245if gt diff get res max_abs
246put res max_abs diff
247end
248if gt rel get res max_rel
249put res max_rel rel
250end
251lim = add get tol atol mul get tol rtol scale
252if gt diff lim
253put res mismatches add get res mismatches 1
254end
255end
256
257fn h2h_check_parity a view f64 * b view f64 * tol view H2hTol res edit H2hParity to void
258put res ok ulong 0
259put res elem_n ulong 0
260put res mismatches ulong 0
261put res nan_cnt ulong 0
262put res inf_cnt ulong 0
263put res max_abs 0.0f64
264put res max_rel 0.0f64
265na = len a
266if eq na 0
267ret
268end
269if ne na len b
270ret
271end
272if gt na H2H_MAX_ELEMS
273ret
274end
275if not h2h_tol_valid tol
276ret
277end
278put res elem_n na
279i = ulong 0
280while lt i na bound 65536
281h2h_parity_step get a i get b i tol res
282i = add i 1
283end
284if eq get res mismatches 0
285if eq get res nan_cnt 0
286if eq get res inf_cnt 0
287put res ok ulong 1
288end
289end
290end
291end
292
293fn h2h_sort_u64 arr edit ulong * n ulong to void
294i = ulong 1
295while lt i n bound 4096
296key = get arr i
297j = i
298while gt j 0 bound 4096
299prev = get arr sub j 1
300if gt prev key
301put arr j prev
302j = sub j 1
303else
304break
305end
306end
307put arr j key
308i = add i 1
309end
310end
311
312fn h2h_pct_idx n ulong pct ulong to ulong
313num = add mul pct n 99
314rank = div num 100
315if eq rank 0
316ret ulong 0
317end
318idx = sub rank 1
319if ge idx n
320ret sub n 1
321end
322ret idx
323end
324
325fn h2h_compute_stats raw view ulong * scratch edit ulong * st edit H2hStats to bool
326put st ok ulong 0
327put st n ulong 0
328put st min_ns ulong 0
329put st q1_ns ulong 0
330put st med_ns 0.0f64
331put st q3_ns ulong 0
332put st iqr_ns ulong 0
333put st p95_ns ulong 0
334put st max_ns ulong 0
335n = len raw
336if eq n 0
337ret false
338end
339if gt n H2H_MAX_SAMPLES
340ret false
341end
342if gt n len scratch
343ret false
344end
345i = ulong 0
346while lt i n bound 4096
347v = get raw i
348if eq v 0
349ret false
350end
351put scratch i v
352i = add i 1
353end
354h2h_sort_u64 scratch n
355minv = get scratch 0
356maxv = get scratch sub n 1
357half = div n 2
358med = 0.0f64
359if eq rem n 2 1
360med = f64 get scratch half
361else
362lo = f64 get scratch sub half 1
363hi = f64 get scratch half
364med = mul 0.5f64 add lo hi
365end
366q1 = get scratch h2h_pct_idx n 25
367q3 = get scratch h2h_pct_idx n 75
368p95 = get scratch h2h_pct_idx n 95
369put st ok ulong 1
370put st n n
371put st min_ns minv
372put st q1_ns q1
373put st med_ns med
374put st q3_ns q3
375put st iqr_ns sub q3 q1
376put st p95_ns p95
377put st max_ns maxv
378ret true
379end
380
381fn h2h_iqr_call sa view H2hStats sb view H2hStats to ulong
382if lt get sb q3_ns get sa q1_ns
383ret H2H_CALL_B_FASTER
384end
385if lt get sa q3_ns get sb q1_ns
386ret H2H_CALL_A_FASTER
387end
388ret H2H_CALL_OVERLAPPING
389end
390
391fn h2h_speedup med_a f64 med_b f64 to f64
392if le med_b 0.0f64
393ret 0.0f64
394end
395if not h2h_f64_is_finite med_a
396ret 0.0f64
397end
398if not h2h_f64_is_finite med_b
399ret 0.0f64
400end
401ret div med_a med_b
402end
403
404fn h2h_bw_gbps bytes_moved ulong med_ns f64 to f64
405if le med_ns 0.0f64
406ret 0.0f64
407end
408if not h2h_f64_is_finite med_ns
409ret 0.0f64
410end
411note bytes per nanosecond equals decimal GB/s (1e9 bytes/s)
412ret div f64 bytes_moved med_ns
413end
414
415fn h2h_make_wrong_kernel_mutant ref_a view f64 * dst edit f64 * to ulong
416n = len ref_a
417if gt n len dst
418ret ulong 0
419end
420if gt n H2H_MAX_ELEMS
421ret ulong 0
422end
423note Deliberate wrong-kernel control: poisons output like coldstart --skip-run / offset error
424i = ulong 0
425while lt i n bound 65536
426v = get ref_a i
427put dst i add neg v 1337.25f64
428i = add i 1
429end
430ret n
431end
432
433fn h2h_verify_mutant ref_a view f64 * mut_b view f64 * tol view H2hTol mres edit H2hParity to bool
434na = len ref_a
435nb = len mut_b
436if or eq na 0 ne na nb
437ret false
438end
439if not h2h_tol_valid tol
440ret false
441end
442h2h_check_parity ref_a mut_b tol mres
443note Control succeeds only when the deliberate wrong kernel FAILS parity
444ret eq get mres ok 0
445end
446
447fn h2h_finalize_summary sa view H2hStats sb view H2hStats par view H2hParity mchk ulong mcaught ulong sum edit H2hSummary to void
448put sum verdict H2H_VERDICT_NOT_RUN
449put sum reason H2H_REASON_OK
450put sum speedup 0.0f64
451put sum bw_a_gbps 0.0f64
452put sum bw_b_gbps 0.0f64
453put sum iqr_call H2H_CALL_OVERLAPPING
454put sum parity_ok get par ok
455put sum mutant_checked mchk
456put sum mutant_caught mcaught
457if or eq get sa n 0 eq get sb n 0
458if or eq get sa ok 0 eq get sb ok 0
459put sum verdict H2H_VERDICT_NOT_RUN
460put sum reason H2H_REASON_NO_PAIRS
461ret
462end
463end
464if or eq get sa ok 0 eq get sb ok 0
465put sum verdict H2H_VERDICT_FAIL
466put sum reason H2H_REASON_BAD_TIMING
467ret
468end
469if ne get sa n get sb n
470put sum verdict H2H_VERDICT_FAIL
471put sum reason H2H_REASON_BAD_TIMING
472ret
473end
474bm = get sum bytes_moved
475put sum speedup h2h_speedup get sa med_ns get sb med_ns
476put sum bw_a_gbps h2h_bw_gbps bm get sa med_ns
477put sum bw_b_gbps h2h_bw_gbps bm get sb med_ns
478put sum iqr_call h2h_iqr_call sa sb
479if eq get par elem_n 0
480put sum verdict H2H_VERDICT_NOT_RUN
481put sum reason H2H_REASON_NO_ELEMS
482ret
483end
484if eq get par ok 0
485put sum verdict H2H_VERDICT_FAIL
486put sum reason H2H_REASON_PARITY_FAIL
487ret
488end
489if eq mchk 0
490put sum verdict H2H_VERDICT_NOT_RUN
491put sum reason H2H_REASON_MUTANT_NOT_RUN
492ret
493end
494if eq mcaught 0
495put sum verdict H2H_VERDICT_FAIL
496put sum reason H2H_REASON_MUTANT_ESCAPED
497ret
498end
499put sum verdict H2H_VERDICT_PASS
500put sum reason H2H_REASON_OK
501end
502
503fn h2h_write_reason fd int reason ulong to void
504ok = false
505if eq reason H2H_REASON_OK
506ok = h2h_write_all fd h2h_t_r_ok
507else
508if eq reason H2H_REASON_NO_PAIRS
509ok = h2h_write_all fd h2h_t_r_nopairs
510else
511if eq reason H2H_REASON_NO_ELEMS
512ok = h2h_write_all fd h2h_t_r_noelems
513else
514if eq reason H2H_REASON_BAD_TIMING
515ok = h2h_write_all fd h2h_t_r_badtime
516else
517if eq reason H2H_REASON_PARITY_FAIL
518ok = h2h_write_all fd h2h_t_r_parfail
519else
520if eq reason H2H_REASON_MUTANT_NOT_RUN
521ok = h2h_write_all fd h2h_t_r_mutnr
522else
523if eq reason H2H_REASON_MUTANT_ESCAPED
524ok = h2h_write_all fd h2h_t_r_mutesc
525else
526ok = h2h_write_all fd h2h_t_r_badtol
527end
528end
529end
530end
531end
532end
533end
534if ok
535ret
536end
537end
538
539fn h2h_write_stats_line fd int is_b ulong st view H2hStats to void
540ok = false
541if eq is_b 0
542ok = h2h_write_all fd h2h_t_arma
543else
544ok = h2h_write_all fd h2h_t_armb
545end
546ok = and ok h2h_write_all fd h2h_t_n
547h2h_write_u64 fd get st n
548ok = and ok h2h_write_all fd h2h_t_min
549h2h_write_u64 fd get st min_ns
550ok = and ok h2h_write_all fd h2h_t_q1
551h2h_write_u64 fd get st q1_ns
552ok = and ok h2h_write_all fd h2h_t_med
553h2h_write_f64_6 fd get st med_ns
554ok = and ok h2h_write_all fd h2h_t_q3
555h2h_write_u64 fd get st q3_ns
556ok = and ok h2h_write_all fd h2h_t_iqr
557h2h_write_u64 fd get st iqr_ns
558ok = and ok h2h_write_all fd h2h_t_p95
559h2h_write_u64 fd get st p95_ns
560ok = and ok h2h_write_all fd h2h_t_max
561h2h_write_u64 fd get st max_ns
562ok = and ok h2h_write_all fd h2h_t_nl
563if ok
564ret
565end
566end
567
568fn h2h_emit_report fd int sa view H2hStats sb view H2hStats par view H2hParity sum view H2hSummary to void
569ok = h2h_write_all fd h2h_t_verdict
570v = get sum verdict
571if eq v H2H_VERDICT_PASS
572ok = and ok h2h_write_all fd h2h_t_pass
573else
574if eq v H2H_VERDICT_FAIL
575ok = and ok h2h_write_all fd h2h_t_fail
576else
577ok = and ok h2h_write_all fd h2h_t_notrun
578end
579end
580ok = and ok h2h_write_all fd h2h_t_reason
581h2h_write_reason fd get sum reason
582ok = and ok h2h_write_all fd h2h_t_nl
583h2h_write_stats_line fd 0 sa
584h2h_write_stats_line fd 1 sb
585ok = and ok h2h_write_all fd h2h_t_cmp
586h2h_write_f64_6 fd get sum speedup
587ok = and ok h2h_write_all fd h2h_t_bwa
588h2h_write_f64_6 fd get sum bw_a_gbps
589ok = and ok h2h_write_all fd h2h_t_bwb
590h2h_write_f64_6 fd get sum bw_b_gbps
591ok = and ok h2h_write_all fd h2h_t_call
592ic = get sum iqr_call
593if eq ic H2H_CALL_B_FASTER
594ok = and ok h2h_write_all fd h2h_t_call_bf
595else
596if eq ic H2H_CALL_A_FASTER
597ok = and ok h2h_write_all fd h2h_t_call_af
598else
599ok = and ok h2h_write_all fd h2h_t_call_ov
600end
601end
602ok = and ok h2h_write_all fd h2h_t_nl
603ok = and ok h2h_write_all fd h2h_t_par
604h2h_write_u64 fd get par ok
605ok = and ok h2h_write_all fd h2h_t_elems
606h2h_write_u64 fd get par elem_n
607ok = and ok h2h_write_all fd h2h_t_mis
608h2h_write_u64 fd get par mismatches
609ok = and ok h2h_write_all fd h2h_t_nan
610h2h_write_u64 fd get par nan_cnt
611ok = and ok h2h_write_all fd h2h_t_inf
612h2h_write_u64 fd get par inf_cnt
613ok = and ok h2h_write_all fd h2h_t_mabs
614h2h_write_f64_6 fd get par max_abs
615ok = and ok h2h_write_all fd h2h_t_mrel
616h2h_write_f64_6 fd get par max_rel
617ok = and ok h2h_write_all fd h2h_t_nl
618ok = and ok h2h_write_all fd h2h_t_mut
619h2h_write_u64 fd get sum mutant_checked
620ok = and ok h2h_write_all fd h2h_t_caught
621h2h_write_u64 fd get sum mutant_caught
622ok = and ok h2h_write_all fd h2h_t_nl
623if ok
624ret
625end
626end
627
628fn h2h_is_ws b uchar to bool
629ret or eq b 32 or eq b 9 eq b 13
630end
631
632fn h2h_skip_ws buf view uchar * pos ulong endpos ulong to ulong
633p = pos
634while lt p endpos bound 1024
635if not h2h_is_ws get buf p
636break
637end
638p = add p 1
639end
640ret p
641end
642
643fn h2h_next_tok_end buf view uchar * pos ulong endpos ulong to ulong
644p = pos
645while lt p endpos bound 1024
646if h2h_is_ws get buf p
647break
648end
649p = add p 1
650end
651ret p
652end
653
654fn h2h_tok_eq buf view uchar * s ulong e ulong lit view uchar * to bool
655ln = len lit
656if ne sub e s ln
657ret false
658end
659i = ulong 0
660while lt i ln bound 64
661if ne get buf add s i get lit i
662ret false
663end
664i = add i 1
665end
666ret true
667end
668
669fn h2h_parse_u64_ok buf view uchar * s ulong e ulong to bool
670if ge s e
671ret false
672end
673if gt sub e s 20
674ret false
675end
676i = s
677while lt i e bound 24
678c = get buf i
679if or lt c 48 gt c 57
680ret false
681end
682i = add i 1
683end
684ret true
685end
686
687fn h2h_parse_u64_val buf view uchar * s ulong e ulong to ulong
688acc = ulong 0
689i = s
690while lt i e bound 24
691d = ulong sub get buf i 48
692acc = add mul acc 10 d
693i = add i 1
694end
695ret acc
696end
697
698fn h2h_parse_f64_ok buf view uchar * s ulong e ulong to bool
699if ge s e
700ret false
701end
702if gt sub e s 32
703ret false
704end
705i = s
706if or eq get buf i 45 eq get buf i 43
707i = add i 1
708end
709if ge i e
710ret false
711end
712digits = ulong 0
713dots = ulong 0
714while lt i e bound 32
715c = get buf i
716if and ge c 48 le c 57
717digits = add digits 1
718else
719if eq c 46
720dots = add dots 1
721if gt dots 1
722ret false
723end
724else
725if or eq c 101 eq c 69
726if eq digits 0
727ret false
728end
729i = add i 1
730if lt i e
731if or eq get buf i 45 eq get buf i 43
732i = add i 1
733end
734end
735edig = ulong 0
736while lt i e bound 16
737ec = get buf i
738if or lt ec 48 gt ec 57
739ret false
740end
741edig = add edig 1
742i = add i 1
743end
744ret gt edig 0
745else
746ret false
747end
748end
749end
750i = add i 1
751end
752ret gt digits 0
753end
754
755fn h2h_pow10_f64 exp int to f64
756res = 1.0f64
757if gt exp 0
758e = ulong exp
759if gt e 300
760e = ulong 300
761end
762i = ulong 0
763while lt i e bound 301
764res = mul res 10.0f64
765i = add i 1
766end
767else
768if lt exp 0
769e = ulong neg exp
770if gt e 300
771e = ulong 300
772end
773i = ulong 0
774while lt i e bound 301
775res = div res 10.0f64
776i = add i 1
777end
778end
779end
780ret res
781end
782
783fn h2h_parse_exp buf view uchar * pos ulong e ulong to int
784i = pos
785sgn = int 1
786if lt i e
787if eq get buf i 45
788sgn = int -1
789i = add i 1
790else
791if eq get buf i 43
792i = add i 1
793end
794end
795end
796ev = int 0
797while lt i e bound 16
798ed = int sub get buf i 48
799ev = add mul ev 10 ed
800i = add i 1
801end
802ret mul sgn ev
803end
804
805fn h2h_parse_f64_val buf view uchar * s ulong e ulong to f64
806i = s
807is_neg = false
808if eq get buf i 45
809is_neg = true
810i = add i 1
811else
812if eq get buf i 43
813i = add i 1
814end
815end
816val = 0.0f64
817frac_div = 1.0f64
818in_frac = false
819exp_total = int 0
820while lt i e bound 32
821c = get buf i
822if and ge c 48 le c 57
823d = f64 sub c 48
824if in_frac
825frac_div = mul frac_div 10.0f64
826val = add val div d frac_div
827else
828val = add mul val 10.0f64 d
829end
830else
831if eq c 46
832in_frac = true
833else
834if or eq c 101 eq c 69
835exp_total = h2h_parse_exp buf add i 1 e
836break
837end
838end
839end
840i = add i 1
841end
842if ne exp_total 0
843val = mul val h2h_pow10_f64 exp_total
844end
845if is_neg
846val = neg val
847end
848ret val
849end