Skip to content

Commit 3246f65

Browse files
committed
fixed double type
1 parent 7e1c597 commit 3246f65

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

src/SciSharp.MySQL.Replication/Types/DoubleType.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,13 @@ class DoubleType : IMySQLDataType
2121
/// <returns>A double value representing the MySQL DOUBLE value.</returns>
2222
public object ReadValue(ref SequenceReader<byte> reader, ColumnMetadata columnMetadata)
2323
{
24-
return BitConverter.Int64BitsToDouble(reader.ReadLong(8));
24+
// MySQL stores DOUBLE values in IEEE 754 double-precision format (8 bytes)
25+
// Read the 8 bytes in big-endian order
26+
Span<byte> buffer = stackalloc byte[8];
27+
reader.TryCopyTo(buffer);
28+
reader.Advance(8);
29+
30+
return BitConverter.ToDouble(buffer);
2531
}
2632
}
2733
}

tests/Test/DataTypesTest.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ await TestDataType<float>("float_table", currentValue, currentValue + 10.55f, (r
119119
});
120120
}
121121

122-
//[Fact]
122+
[Fact]
123123
public async Task TestDoubleType()
124124
{
125125
var currentValue = 123456.789012;

0 commit comments

Comments
 (0)