Skip to content

Commit

Permalink
Fix errors in Github CI.
Browse files Browse the repository at this point in the history
  • Loading branch information
ibireme committed Aug 25, 2024
1 parent 11fd82c commit 8c5544d
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
5 changes: 3 additions & 2 deletions src/yyjson.c
Original file line number Diff line number Diff line change
Expand Up @@ -7258,7 +7258,7 @@ static_inline u8 *write_u32_len_1_to_9(u32 val, u8 *buf) {
if (val >= 100000000) {
u32 hi = val / 10000000;
val = val - hi * 10000000;
*buf++ = (u8)hi + '0';
*buf++ = (u8)hi + (u8)'0';
}
return write_u32_len_1_to_8((u32)val, buf);
}
Expand Down Expand Up @@ -8094,7 +8094,8 @@ static_noinline u8 *write_f64_raw_fixed(u8 *buf, u64 raw, yyjson_write_flag flg,
/* update exp and sig length */
exp_dec += sig_len_cut;
sig_len -= sig_len_cut;
sig_len += (sig_dec >= u64_pow10_table[sig_len]);
sig_len += (sig_len >= 0) &&
(sig_dec >= div_pow10_table[sig_len].p10);
}
if (sig_len <= 0) {
byte_copy_4(buf, "0.0");
Expand Down
2 changes: 1 addition & 1 deletion src/yyjson.h
Original file line number Diff line number Diff line change
Expand Up @@ -4974,7 +4974,7 @@ yyjson_api_inline void unsafe_yyjson_set_fp_to_float(void *val, bool flt) {
yyjson_api_inline void unsafe_yyjson_set_float(void *val, float num) {
unsafe_yyjson_set_tag(val, YYJSON_TYPE_NUM, YYJSON_SUBTYPE_REAL, 0);
((yyjson_val *)val)->tag |= (uint64_t)YYJSON_WRITE_FP_TO_FLOAT << 32;
((yyjson_val *)val)->uni.f64 = num;
((yyjson_val *)val)->uni.f64 = (double)num;
}

yyjson_api_inline void unsafe_yyjson_set_double(void *val, double num) {
Expand Down
5 changes: 5 additions & 0 deletions test/test_number.c
Original file line number Diff line number Diff line change
Expand Up @@ -463,6 +463,11 @@ static void validate_real_output(const char *str,
expect(f64_read(buf, &num) > 0);
expect(out_num == num);

char *dot = strchr(str, '.');
expect(dot != NULL);
usize digits_after_dot = strlen(str) - (usize)(dot - str) - 1;
expect(digits_after_dot <= (usize)to_fixed);

} else {
#if FP_USE_LIBC
// To shortest.
Expand Down

0 comments on commit 8c5544d

Please sign in to comment.