use Ryu for number formatting for %f
This commit is contained in:
parent
ca9d76c9a6
commit
339bc8ced6
@ -206,6 +206,9 @@ i32 num_fmt(char buf[30], f64 x) {
|
|||||||
return len;
|
return len;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if !NO_RYU
|
||||||
|
B ryu_d2s(double f);
|
||||||
|
#endif
|
||||||
static B appendRaw(B s, B x) { assert(isArr(x) && RNK(x)==1); // consumes x
|
static B appendRaw(B s, B x) { assert(isArr(x) && RNK(x)==1); // consumes x
|
||||||
AJOIN(squeeze_chrOut(x));
|
AJOIN(squeeze_chrOut(x));
|
||||||
return s;
|
return s;
|
||||||
@ -315,8 +318,13 @@ NOINLINE B do_fmt(B s, char* p, va_list a) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 'f': {
|
case 'f': {
|
||||||
NUM_FMT_BUF(buf, va_arg(a, f64));
|
f64 val = va_arg(a, f64);
|
||||||
AU(buf);
|
#if NO_RYU
|
||||||
|
NUM_FMT_BUF(buf, val);
|
||||||
|
AU(buf);
|
||||||
|
#else
|
||||||
|
AJOIN(ryu_d2s(val));
|
||||||
|
#endif
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 'c': {
|
case 'c': {
|
||||||
|
|||||||
@ -407,6 +407,12 @@ b←1↓1∾a←"hello" ⋄ b ⌽⎊'e' ⥊⟜1⍟2 5 ⋄ a ≡○•Hash b %% 1
|
|||||||
!"↕𝕩: 𝕩 must be either an integer or integer list (had rank 2)" % ↕2‿2⥊1
|
!"↕𝕩: 𝕩 must be either an integer or integer list (had rank 2)" % ↕2‿2⥊1
|
||||||
!"↕𝕩: Result rank too large (300≡≠𝕩)" % ↕300⥊1
|
!"↕𝕩: Result rank too large (300≡≠𝕩)" % ↕300⥊1
|
||||||
!"↕𝕩: Result too large" % ↕20⥊10
|
!"↕𝕩: Result too large" % ↕20⥊10
|
||||||
|
!"Expected non-negative integer, got 3000.0000000000005" % ↕1e4×1.3-1
|
||||||
|
!"Expected non-negative integer, got ¯3000.0000000000005" % ↕-1e4×1.3-1
|
||||||
|
!"Expected non-negative integer, got ¯10000" % ↕-1e4
|
||||||
|
!"Out of memory" % ↕2e9 %USZ32
|
||||||
|
!"Out of memory" % ↕1e18 %USZ64
|
||||||
|
!"Integer out of range: 1e20" % ↕1e20
|
||||||
↕⟨⟩ %% <↕0
|
↕⟨⟩ %% <↕0
|
||||||
≢↕↕100 %% ↕100
|
≢↕↕100 %% ↕100
|
||||||
↕⋈10 %% ⋈¨ ↕10
|
↕⋈10 %% ⋈¨ ↕10
|
||||||
|
|||||||
@ -328,8 +328,8 @@ r←•MakeRand 1 ⋄ ! 1¨⊸≡ ∊{𝕊: 500 r.Deal 1000}¨ ↕4
|
|||||||
|
|
||||||
!"•bit._cast: unsupported width 1073741824" % (2⥊2⋆30)•bit._cast ⋈0
|
!"•bit._cast: unsupported width 1073741824" % (2⥊2⋆30)•bit._cast ⋈0
|
||||||
!"•bit._cast: unsupported width 1125899906842624" % (2⥊2⋆50)•bit._cast ⋈0 %USZ64
|
!"•bit._cast: unsupported width 1125899906842624" % (2⥊2⋆50)•bit._cast ⋈0 %USZ64
|
||||||
!"Integer out of range: 1125899906842624" % (2⥊2⋆50)•bit._cast ⋈0 %USZ32
|
!"Integer out of range: 1.125899906842624e15" % (2⥊2⋆50)•bit._cast ⋈0 %USZ32
|
||||||
!"Integer out of range: 1.180591620717411e21" % (2⥊2⋆70)•bit._cast ⋈0
|
!"Integer out of range: 1.1805916207174113e21" % (2⥊2⋆70)•bit._cast ⋈0
|
||||||
!"Integer out of range: ∞" % (2⥊∞)•bit._cast ⋈0
|
!"Integer out of range: ∞" % (2⥊∞)•bit._cast ⋈0
|
||||||
|
|
||||||
!"•bit._cast: unsupported width 12" % 1‿12•bit._cast 11⥊0
|
!"•bit._cast: unsupported width 12" % 1‿12•bit._cast 11⥊0
|
||||||
|
|||||||
@ -177,7 +177,7 @@ n←500 ⋄ a←↕n ⋄ i←(-n)+↕2×n ⋄ r←⌽(2×n)⥊a ⋄ ! (⌽a) ≡
|
|||||||
%USE eqvar ⋄ <‿≥‿> {𝕨⌾(1‿0‿0‿1‿1⊸/) 𝕩}_eqvar +‿-‿×‿÷‿⋆ %% <‿-‿×‿≥‿>
|
%USE eqvar ⋄ <‿≥‿> {𝕨⌾(1‿0‿0‿1‿1⊸/) 𝕩}_eqvar +‿-‿×‿÷‿⋆ %% <‿-‿×‿≥‿>
|
||||||
%USE eqvar ⋄ ["wx"‿"WX","yz"‿"YZ"] {𝕨⌾(1‿0‿0‿1⊸/) 𝕩}_eqvar (<"aA")+↕4‿2 %% 4‿2⥊⟨"wx","WX","bA","bB","cA","cB","yz","YZ"⟩
|
%USE eqvar ⋄ ["wx"‿"WX","yz"‿"YZ"] {𝕨⌾(1‿0‿0‿1⊸/) 𝕩}_eqvar (<"aA")+↕4‿2 %% 4‿2⥊⟨"wx","WX","bA","bB","cA","cB","yz","YZ"⟩
|
||||||
{m←𝕩•rand.Range 2 ⋄ ! (m{𝕨?"huh";⥊'a'+𝕩}¨↕𝕩) ≡ "huh"¨⌾(m⊸/) 'a'+↕⋈𝕩}¨ ↕100
|
{m←𝕩•rand.Range 2 ⋄ ! (m{𝕨?"huh";⥊'a'+𝕩}¨↕𝕩) ≡ "huh"¨⌾(m⊸/) 'a'+↕⋈𝕩}¨ ↕100
|
||||||
!"Integer out of range: 3.68934881474191e19" % 1¨⌾(a⊸/) a←100⥊2⋆65
|
!"Integer out of range: 3.6893488147419103e19" % 1¨⌾(a⊸/) a←100⥊2⋆65
|
||||||
!"Expected non-negative integer, got ¯10" % %USE evar ⋄ 1¨⌾(a⊸/)_evar a←¯10⌾(50⊸⊑) 100⥊10
|
!"Expected non-negative integer, got ¯10" % %USE evar ⋄ 1¨⌾(a⊸/)_evar a←¯10⌾(50⊸⊑) 100⥊10
|
||||||
|
|
||||||
# ↓ & ↑
|
# ↓ & ↑
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user