[Qt-interest] strange qFuzzyCompare implementation
Konrad Rosenbaum
konrad at silmor.de
Mon Apr 13 20:15:06 CEST 2009
On Monday 13 April 2009, Reinhardt Behm wrote:
> Your "solution" is totally unportable because your assumptions about the
> representation of float numbers will only be correct on a x86 evironment.
Wrong. It is designed to work with IEEE 754 floats, which are stored in the
same endianess as integers on this platform.
Works on x86, x64, and most big-endian systems. Probably most systems.
> And even there some compiler implementation might store floats
> differently.
Very unlikely.
> Try running it on e.g. an ARM platform and it will not word
> at all.
I doubt that. (Until someone shows me program output from an actual ARM or
ARM emulator. Please include the sizeof output of the chosen types.)
> This is no solution for a multiplatform toolkit like Qt.
Besides my doubts for your pessimism, it is still not a good solution for
cross-platform, since it needs platform dependent adjustments for endianess
and the used int types. On some platforms it might(!) not work at all.
Not that Qt would not already contain quite a few platform dependent header
files (guess where stuff like qint32 comes from), but this might be too
much.
> Besides it is bad programming style to rely on such undocumented
> behaviour.
The behaviour is documented in IEEE 754.
Konrad
--
Note: I'm changing my PGP/GPG key soon! New KeyID: 723A6200
Fingerprint: B37C FA75 8C4C 6537 7954 CBC0 CB15 C991 723A 6200
Keyserver: wwwkeys.eu.pgp.net
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: not available
Url : http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20090413/468a4356/attachment.bin
More information about the Qt-interest-old
mailing list