|
From: | Michael Hennebry |
Subject: | Re: [Help-glpk] glp_mip_col_val is returning negative zero |
Date: | Mon, 4 May 2015 11:37:29 -0500 (CDT) |
User-agent: | Alpine 1.00 (DEB 882 2007-12-20) |
On Fri, 1 May 2015, Andrew Makhorin wrote:
On Fri, 2015-05-01 at 15:17 +0000, Agostina Kodelia wrote:Hi! I'm solving a very simple postman travelling problem with the glp_intopt method. When I retrieved the column value with glp_mip_col_val, it returns a negative zero. The zero is alright, but I don't understand why has a minus, could anyone explain to me why is this happening?This is because the IEEE 754 standard which most of modern FPUs conform to claims that a floating-point zero has the sign bit. A negative zero may appear, for example, on computing (2. - 3.) * (5. - 5.) = -1. * +0. = -0.
The minus sign was not actually necessary. C89 is not required to notice the sign of zero. That printf did suggests that its author made a special effort. So far as I know, none of C89's successors are required to notice the sign of zero. C99 implementations *may* choose to honor IEEE floating point and to note the fact in a C99-defined preprocessor symbol. C99 defines said choice to include noticing the sign of zero. -- Michael address@hidden "SCSI is NOT magic. There are *fundamental technical reasons* why it is necessary to sacrifice a young goat to your SCSI chain now and then." -- John Woods
[Prev in Thread] | Current Thread | [Next in Thread] |