Hello Daniel,
for some reason, we have set the control flag for raising invalid number
exceptions. On default this is disabled*. The SSE2 instruction cvttss2si,
which causes the problem, does return indefinite integer value (80000000H)
if the exception is masked**. I.e. without taking proper action the unit
test shouldn't see the problem?
Additionally, the problem is 64 bit specific. On 32 bit it would be
necessary to explicitely compile with SSE2 support. On 64 bit SSE2 is always
used*.
*http://msdn.microsoft.com/en-us/library/windows/hardware/ff545910%28v=vs.85%...
**http://www.jaist.ac.jp/iscenter-new/mpc/altix/altixdata/opt/intel/vtune/doc/...
I see two problems running the unit test:
1. I would have to setup the runtime for 64 bit including the mentioned
exception mask.
2. I'm not proficient in the usage of the unit test framework.
How can I change the hash function used for floats and doubles,
respectively?
Do you have an example for hashing the binary representation?
I also use the multi_index container with a hashed_index on floats. I see
the very same problems lurking on this side. If this is a real problem it
might be worth to change the implementation of the hash function in general?
Best
Johannes
"Daniel James"
On 21 August 2012 09:47, Johannes Brunen
wrote: Now I have some questions: 1. Is it known that this mapping into the realm of 32Bit is happening for the above cast operation? 2. Is this a compiler bug? The generated assembler code does not allow 'safe' casting into 64bit integer? 3. Any advice how I should handle this situation?
This is certainly surprising. I'll need to look into it some more, but the best course is probably to use a different technique for hashing floats with Visual C++. I'm already directly hashing the binary representation of floating point numbers on cygwin, so could probably do the same for Visual C++, it'll also be a bit quicker.
I'm a bit surprised this wasn't caught by the unit tests. Can you try running the hash unit tests? They're at 'libs/functional/hash/test' - especially 'hash_float_test.cpp' and 'hash_long_double_test.cpp'.