64-bit HNumber
Originally reported on Google Code with ID 290 ``` I was attempting to implement a endian swap function for 64-bit values, but this doesn't seem to work correctly. Here's the function: HNumber Functions::Private::lswap( Function *, const QVector<HNumber> & args ) { HNumber x = args.at(0);
return ( x >> 56) | ((x << 40) & 0x00FF000000000000) | ((x << 24) & 0x0000FF0000000000) | ((x << 8) & 0x000000FF00000000) | ((x >> 8) & 0x00000000FF000000) | ((x >> 24) & 0x0000000000FF0000) | ((x >> 40) & 0x000000000000FF00) | ( x << 56); }
The problem is that the application tries to turn the constant &-values (e.g. 0x00FF000000000000) into an HNumber as well, but the constructor for this object only accepts int values. As a result, the value is truncated and the function produces incorrect results.
Any ideas how to prevent this?
The swap functions for ints and shorts work just fine (as expected). ```
Reported by `1100101` on 2009-05-29 09:09:51
Comments (1)
-
Account Deleted - Log in to comment
``` You have to write an overloaded HNumber operator & (const HNumber&, int64_t) to make your code work *exactly* the way your example suggests. It's easier to turn your hex encoded integers into decimal numbers and use HNumber("1234567890987654321") instead.
This is related to C++ and an internal detail of Speedcrunch not visible on the outside, and neither a bug nor a feature request nor an enhancement, so I turn this into invalid. ```
Reported by `wolf.lammen` on 2009-05-29 13:54:42 - Status changed: `Invalid`