nota write decimal numbers via a string in the qjs_nota implementation, solving windows fp error

This commit is contained in:
2025-02-24 20:22:11 -06:00
parent 6c390aeae3
commit af0996f6ab
3 changed files with 180 additions and 5 deletions

View File

@@ -150,14 +150,19 @@ static void nota_encode_value(NotaEncodeContext *enc, JSValueConst val)
int tag = JS_VALUE_GET_TAG(val);
switch (tag) {
case JS_TAG_INT:
case JS_TAG_INT: {
double d;
JS_ToFloat64(ctx, &d, val);
nota_write_number(&enc->nb, d);
return;
}
case JS_TAG_BIG_INT:
case JS_TAG_FLOAT64:
case JS_TAG_BIG_DECIMAL:
case JS_TAG_BIG_FLOAT: {
double d;
JS_ToFloat64(ctx, &d, val);
nota_write_number(&enc->nb, d);
const char *str = JS_ToCString(ctx, val);
nota_write_number_str(&enc->nb, str);
JS_FreeCString(ctx, str);
return;
}