Date: Monday, January 15, 2007 @ 15:28:09
Author: marc
Path: /cvsroot/carob/carob/src
Modified: SQLDataSerialization.cpp (1.39 -> 1.40)
Better explanation of endianness tests at startup time
--------------------------+
SQLDataSerialization.cpp | 16 ++++++++++++----
1 files changed, 12 insertions(+), 4 deletions(-)
Index: carob/src/SQLDataSerialization.cpp
diff -u carob/src/SQLDataSerialization.cpp:1.39
carob/src/SQLDataSerialization.cpp:1.40
--- carob/src/SQLDataSerialization.cpp:1.39 Mon Jan 15 14:00:28 2007
+++ carob/src/SQLDataSerialization.cpp Mon Jan 15 15:28:09 2007
@@ -368,15 +368,23 @@
// build some magical float constants
- // e125f = 2^-125, so we have: s = 0, e = 2, m = 0 (first '1' in m
- // is implicit). So that's just one bit set to '1' in the higher
- // (s/e) byte, and all the rest is '0'
+ // e125f = 2^-125, so we have: sign = 0, exponent = 2, mantissa =
+ // 0 (first '1' in m is implicit). So that's just one bit set to
+ // '1' in the hybrid (sign/exponent) octet, and all the other bits
+ // are '0'
float e125f_ = 1;
for (int i=0; i < 5; i++)
e125f_ /= (1 << 25);
- // insert a '1' in the digit before the last
+
+ // In the mantissa, set the bit before the least significant to
+ // '1'. That should set the least significant byte of the mantissa
+ // to '2'
float e125fbis_ = e125f_ + e125f_ / (1 << 22);
+ // so now e125fbis_ should look in memory either like { 1, 0, 0,
+ // 2} or like { 2, 0, 0, 1}, depending on endianness. Let's go and
+ // check that.
+
const uint32_t e125f = F2I(e125fbis_);
const char *e125f_uc = reinterpret_cast<const char*>(&e125f);
_______________________________________________
Carob-commits mailing list
[email protected]
https://forge.continuent.org/mailman/listinfo/carob-commits