|
|
Choosing A Webhost: |
CVS update of carob/src (SQLDataSerialization.cpp): msg#00187db.carob.cvs
Date: Thursday, January 26, 2006 @ 16:51:20 Author: marc Path: /cvsroot/carob/carob/src Modified: SQLDataSerialization.cpp (1.18 -> 1.19) Simplified a bit floats_little_endianness() and ints_little_endianness() --------------------------+ SQLDataSerialization.cpp | 56 +++++++++++++++++++++++++-------------------- 1 files changed, 32 insertions(+), 24 deletions(-) Index: carob/src/SQLDataSerialization.cpp diff -u carob/src/SQLDataSerialization.cpp:1.18 carob/src/SQLDataSerialization.cpp:1.19 --- carob/src/SQLDataSerialization.cpp:1.18 Wed Jan 25 23:59:02 2006 +++ carob/src/SQLDataSerialization.cpp Thu Jan 26 16:51:20 2006 @@ -36,12 +36,12 @@ // by Java's DataOutput class #ifndef __STDC_IEC_559__ -#error only IEEE 754 platforms are supported +#error "only IEEE 754 platforms are supported" #endif // run-time equivalent is: numeric_limits<double|float>.is_iec559() #if (CHAR_BIT != 8) -#error CHAR_BIT != 8 is not supported +#error "CHAR_BIT != 8 is not supported" #endif using std::wstring; @@ -335,9 +335,11 @@ // insert a '1' in the digit before the last float e125fbis_ = e125f_ + e125f_ / (1 << 22); - uint32_t e125f = F2I(e125f_); - uint32_t e125fbis = F2I(e125fbis_); + const uint32_t e125f = F2I(e125f_); + const uint32_t e125fbis = F2I(e125fbis_); + const unsigned char *e125f_uc = reinterpret_cast<const unsigned char*>(&e125f); + const unsigned char *e125fbis_uc = reinterpret_cast<const unsigned char*>(&e125fbis); // build some magical double constants @@ -348,24 +350,27 @@ // insert a '1' in the digit before the last double e1007dbis_ = e1007d_ + e1007d_ / ((uint64_t) 1 << 51); - uint64_t e1007d = D2I(e1007d_); - uint64_t e1007dbis = D2I(e1007dbis_); + const uint64_t e1007d = D2I(e1007d_); + const uint64_t e1007dbis = D2I(e1007dbis_); + + const unsigned char *e1007d_uc = reinterpret_cast<const unsigned char*>(&e1007d); + const unsigned char *e1007dbis_uc = reinterpret_cast<const unsigned char*>(&e1007dbis); // then check if we have an classical MSB-float arch // (sign, exponent, fraction) // UNTESTED - if (reinterpret_cast<unsigned char*>(&e125f)[0] == 1 - && reinterpret_cast<unsigned char*>(&e125fbis)[3] == 2 - && reinterpret_cast<unsigned char*>(&e1007d)[0] == 1 - && reinterpret_cast<unsigned char*>(&e1007dbis)[7] == 2) + if (e125f_uc[0] == 1 + && e125fbis_uc[3] == 2 + && e1007d_uc[0] == 1 + && e1007dbis_uc[7] == 2) return false; // else check if we have an classical LSB-float arch // TESTED (on IA32) - if (reinterpret_cast<unsigned char*>(&e125f)[3] == 1 - && reinterpret_cast<unsigned char*>(&e125fbis)[0] == 2 - && reinterpret_cast<unsigned char*>(&e1007d)[7] == 1 - && reinterpret_cast<unsigned char*>(&e1007dbis)[0] == 2) + if (e125f_uc[3] == 1 + && e125fbis_uc[0] == 2 + && e1007d_uc[7] == 1 + && e1007dbis_uc[0] == 2) return true; // else weird unsupported arch, abort @@ -375,24 +380,27 @@ bool ints_little_endianness() { - uint32_t i = 0x01000002U; - uint64_t l = 0x0100000000000002ULL; + const uint32_t I = 0x01000002U; + const uint64_t L = 0x0100000000000002ULL; + + const unsigned char *i_uc = reinterpret_cast<const unsigned char*>(&I); + const unsigned char *l_uc = reinterpret_cast<const unsigned char*>(&L); // then check if we have an classical MSB-float arch // (sign, exponent, fraction) // UNTESTED - if (reinterpret_cast<unsigned char*>(&i)[0] == 1 - && reinterpret_cast<unsigned char*>(&i)[3] == 2 - && reinterpret_cast<unsigned char*>(&l)[0] == 1 - && reinterpret_cast<unsigned char*>(&l)[7] == 2) + if (i_uc[0] == 1 + && i_uc[3] == 2 + && l_uc[0] == 1 + && l_uc[7] == 2) return false; // else check if we have an classical LSB-float arch // TESTED (on IA32) - if (reinterpret_cast<unsigned char*>(&i)[3] == 1 - && reinterpret_cast<unsigned char*>(&i)[0] == 2 - && reinterpret_cast<unsigned char*>(&l)[7] == 1 - && reinterpret_cast<unsigned char*>(&l)[0] == 2) + if (i_uc[3] == 1 + && i_uc[0] == 2 + && l_uc[7] == 1 + && l_uc[0] == 2) return true; // else weird unsupported arch, abort
|
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| Previous by Date: | CVS update of libmysequoia/src (CarobStmt.cpp), zsolt-Tt5JLJuBijYiZlD9aYmxOGD2FQJk+8+b |
|---|---|
| Next by Date: | CVS update of carob/src (SQLDataSerialization.cpp), marc-Tt5JLJuBijYiZlD9aYmxOGD2FQJk+8+b |
| Previous by Thread: | CVS update of carob/src (SQLDataSerialization.cpp), marc-Tt5JLJuBijYiZlD9aYmxOGD2FQJk+8+b |
| Next by Thread: | CVS update of carob/src (SQLDataSerialization.cpp), marc-Tt5JLJuBijYiZlD9aYmxOGD2FQJk+8+b |
| Indexes: | [Date] [Thread] [Top] [All Lists] |
Free MagazinesCisco NewsReceive a free quarterly e-newsletter with exclusive articles on how Cisco IT uses its own products and solutions to enable the business. subscribe Systems Management News, the newspaper for IT systems administration and data center managers! Each issue of Systems Management News is chock-full of news and analysis to help you understand what's happening in your field. subscribe The Enterprise Newsweekly eWeek is the essential technology information source for builders of e-business. subscribe Oracle Magazine Oracle Magazine contains technology strategy articles, sample code, tips, Oracle and partner news, how to articles for developers and DBAs, and more. Oracle (NASDAQ: ORCL) is the world's largest enterprise software company. subscribe Total Telecom Total Telecom is "The Economist of the communications industry". subscribe |
Home
| advertise | OSDir is
an inevitable website.
|