简体   繁体   中英

Meaning of -1.58839967e+038 in Visual Studio C++ debugger

I am aware of scientific notation , but I am not sure what that number ( -1.58839967e+038 ) exactly means.

It is supposed to be really close to 0, but it says e+038 so it looks like -1.5 * 10 ^ 38 (as there is a + )

Could someone help me out with that meaning, please? Thanks.

Yes, -1.58839967e+038 is about -1.588×10 38 , a negative number of large magnitude. It happens to be about 47% of the largest value typically representable in type float but that's probably not relevant.

Expressed in English, it would be about -158.8 undecillion , not a number that's particularly likely to be meaningful unless you're doing large-scale astrophysics.

If it's stored in an object of type float , assuming the typical IEEE 32-bit representation, then its representation happens to be equivalent to 0xfeeefeee , which looks suspicious.

Here's a program that demonstrates this:

#include <stdio.h>
int main(void) {
    union {
        float f;
        unsigned int u;
    } u;
    if (sizeof (float) != sizeof (unsigned int)) {
        puts("WARNING: float and unsigned int differ in size");
    }
    u.f = -1.58839967e+038;
    printf("0x%x\n", u.u);
}

The output is:

0xfeeefeee

A Google search for "FEEEFEEE" turned up a Wikipedia article on "magic numbers" which includes the following:

FEEEFEEE

"Fee fee", Used by Microsoft's debug HeapFree() to mark freed heap memory. Some nearby internal bookkeeping values may have the high word set to FEEE as well.

A footnote points to http://www.nobugs.org/developer/win32/debug_crt_heap.html

When converted to hexadecimal (using this site ), you can see this value is actually 0xFEEEFEEE.

According to the list of magic numbers here :

FEEEFEEE : "Fee fee", Used by Microsoft's debug HeapFree() to mark freed heap memory. Some nearby internal bookkeeping values may have the high word set to FEEE as well.

So it might be a deleted struct, or a memory overrun or anything like that. I can't tell exactly without your code.

The value displayed as -1.58839967e+038 is indeed in a form of scientific notation. I believe this use of E dates back to FORTRAN, and I personally have seen the notation in use since I first encountered computers in the late 1970s.

The number is nearly the largest possible negative value that can be represented in an IEEE-754 32-bit (aka single precision) binary floating point value. I would not describe it as close to zero.

The true largest magnitude is +/- 3.4028235E+38 .

A nice site that shows the detailed storage and arrangement of the bits that make up a floating point value is this calculator . From that you can see that the value you name is stored in memory as the 32-bit value 0xfeeefeed . That values isn't quite as suspicious as 0xdeadbeef , but it does seem a little too patterned to be just the result of a calculation.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM