If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
Floating point error?
The following C code:
float f = 5.15002; double d = 5.15002; if (d + FLT_EPSILON f) puts("huh?"); Where 'FLT_EPSILON' is defined as the minimum number whereby 1.0 + FLT_EPSILON != 1.0, causes the string "huh!" to be printed out on my system (Pentium III) I have included the relevant assembly code below. Now is this a bug in the intel chip, or allowable because FLT_EPSILON makes no promises when added to numbers greater than 1.0? It doesn't happen when 'd' is another float, so presumably it has something to do with double-precision/single-precision conversions too. Curious... Dylan 8: float f = 5.15002; 00401028 C7 45 FC F7 CC A4 40 mov dword ptr [ebp-4],40A4CCF7h 9: double d = 5.15002; 0040102F C7 45 F4 D2 FB C6 D7 mov dword ptr [ebp-0Ch],0D7C6FBD2h 00401036 C7 45 F8 9E 99 14 40 mov dword ptr [ebp-8],4014999Eh 10: if (d + FLT_EPSILON f) 0040103D DD 45 F4 fld qword ptr [ebp-0Ch] 00401040 DC 05 28 60 42 00 fadd qword ptr [__real@8@3fe88000000000000000 (00426028)] 00401046 D9 45 FC fld dword ptr [ebp-4] 00401049 DE D9 fcompp 0040104B DF E0 fnstsw ax 0040104D F6 C4 41 test ah,41h 00401050 75 0D jne main+4Fh (0040105f) 11: puts("huh?"); 00401052 68 1C 60 42 00 push offset string "huh?" (0042601c) 00401057 E8 34 00 00 00 call puts (00401090) 0040105C 83 C4 04 add esp,4 12: return 0; 0040105F 33 C0 xor eax,eax |
Thread Tools | |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
A7N8X Motherboard Low Temperature Sensitivity, CMOS Checksum Error | kony | Asus Motherboards | 0 | October 10th 04 06:32 AM |
Getting a weird Promise RAID (Win XP) error with my ASUS P4C800 Deluxe | M. B. | Asus Motherboards | 5 | February 9th 04 12:19 AM |
Western Digital_WD400BB-53C1B0 40GIG + ActiveSmart "Seek Error Rate" ? | bcool | Storage (alternative) | 5 | November 14th 03 07:37 PM |
9500pro ati2mtag ERROR... Regular Omega Drivers v2474a or Hacked version ??? ... | markOpolis | Ati Videocards | 0 | September 3rd 03 01:43 AM |
9500pro ati2mtag ERROR... Regular Omega Drivers v2474a or Hacked version ??? ... | WyreTheWolf | Ati Videocards | 0 | August 31st 03 12:22 PM |