fix %f and clarify o2s message

This commit is contained in:
dzaima 2021-08-22 23:20:28 +03:00
parent 0899ee31b3
commit a3f87d4dcb
2 changed files with 2 additions and 2 deletions

View File

@ -261,7 +261,7 @@ NOINLINE B do_fmt(B s, char* p, va_list a) {
}
case 'f': {
NUM_FMT_BUF(buf, va_arg(a, f64));
A8(buf);
AU(buf);
break;
}
case 'c': {

View File

@ -337,7 +337,7 @@ static B m_i32(i32 n) { return m_f64(n); }
static B m_usz(usz n) { return n<I32_MAX? m_i32((i32)n) : m_f64(n); }
static i32 o2i (B x) { if (x.f!=(f64)(i32)x.f) thrM("Expected integer"); return (i32)x.f; } // i have no clue whether these consume or not, but it doesn't matter
static usz o2s (B x) { if (x.f!=(f64)(usz)x.f) thrM("Expected integer"); return (usz)x.f; }
static usz o2s (B x) { if (x.f!=(f64)(usz)x.f) thrM("Expected non-negative integer"); return (usz)x.f; }
static i64 o2i64 (B x) { if (x.f!=(f64)(i64)x.f) thrM("Expected integer"); return (i64)x.f; }
static u64 o2u64 (B x) { if (x.f!=(f64)(u64)x.f) thrM("Expected integer"); return (u64)x.f; }
static f64 o2f (B x) { if (!isNum(x)) thrM("Expected integer"); return x.f; }