[Carpet] hdf5toascii_slicer: integer constant overflows (prevents compiling)
Erik Schnetter
schnetter at cct.lsu.edu
Mon Aug 21 05:56:46 CEST 2006
On Aug 20, 2006, at 16:24:07, Jonathan Thornburg wrote:
> The fix is easy: just change the literal to floating-point (since
> that's
> how it's used anyway):
> #define SLICECOORD_UNSET -424242424242.0 // this is about
> 2**39 in
> // magnitude,
> small enough to
> // be exactly
> represented in
> // IEEE 'double'
> floating point
> // (this is
> important because
> // later code
> tests if values
> // are == or !=
> this #define)
> static double slice_coord[3] = {SLICECOORD_UNSET,
> SLICECOORD_UNSET, SLICECOORD_UNSET};
Just to nitpick: What about
static double const slicecoord_unset = -424242.0
instead? It's more C++y, it's type-safe since it uses a constant
instead of a macro, and it can even be converted into an integer
without overflow.
-erik
--
Erik Schnetter <schnetter at cct.lsu.edu>
My email is as private as my paper mail. I therefore support encrypting
and signing email messages. Get my PGP key from www.keyserver.net.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: PGP.sig
Type: application/pgp-signature
Size: 186 bytes
Desc: This is a digitally signed message part
Url : /archives/developers/attachments/20060820/d89bb939/attachment.pgp
More information about the developers
mailing list