Skip to content

Commit ecd7094

Browse files
authored
strings: fix write_decimal() for min_i64 (#25638)
1 parent 706179f commit ecd7094

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

vlib/strings/builder.c.v

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ pub fn (mut b Builder) write_decimal(n i64) {
8181
return
8282
}
8383
mut buf := [25]u8{}
84-
mut x := if n < 0 { -n } else { n }
84+
mut x := if n < 0 { u64(-n) } else { u64(n) }
8585
mut i := 24
8686
for x != 0 {
8787
nextx := x / 10

vlib/strings/builder_test.v

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,7 @@ fn test_write_decimal() {
165165
assert sb_i64_str(-1234567890) == '-1234567890'
166166
assert sb_i64_str(9223372036854775807) == '9223372036854775807'
167167
assert sb_i64_str(-9223372036854775807) == '-9223372036854775807'
168+
assert sb_i64_str(min_i64) == '-9223372036854775808'
168169
}
169170

170171
fn test_grow_len() {

0 commit comments

Comments
 (0)