File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1819,7 +1819,7 @@ pub fn PackWithLimits(
18191819
18201820 /// write float
18211821 fn writeFloat (self : Self , val : f64 ) ! void {
1822- // A value should only be encoded as f32 if it can be
1822+ // A value should only be encoded as f32 if it can be
18231823 // represented exactly without loss of precision.
18241824 const val_f32 : f32 = @floatCast (val );
18251825 if (val == @as (f64 , val_f32 )) {
Original file line number Diff line number Diff line change @@ -1140,21 +1140,21 @@ test "large integer float precision (issue fix)" {
11401140 // Test large integer that cannot fit in f32 mantissa (24 bits)
11411141 // 1774904202196 requires 41 bits, so it will lose precision if encoded as f32
11421142 const large_int : f64 = 1774904202196.0 ;
1143-
1143+
11441144 try p .write (.{ .float = large_int });
1145-
1145+
11461146 // Verify it was encoded as f64 (marker 0xcb) not f32 (marker 0xca)
11471147 try expect (arr [0 ] == 0xcb ); // Should use f64 format
1148-
1148+
11491149 // Read back and verify exact match (no truncation)
11501150 read_buffer = fixedBufferStream (& arr );
11511151 p = pack .init (& write_buffer , & read_buffer );
11521152 const val = try p .read (allocator );
11531153 defer val .free (allocator );
1154-
1154+
11551155 // Should preserve the exact value with f64 encoding
11561156 try expect (val .float == large_int );
1157-
1157+
11581158 // Additional test: verify f32 would lose precision
11591159 const large_f32 : f32 = @floatCast (large_int );
11601160 const large_back_to_f64 : f64 = @as (f64 , large_f32 );
You can’t perform that action at this time.
0 commit comments