Regarding Negative point & floating point comparisions

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
sampath
Posts: 18
Joined: Wed Dec 20, 2006 4:00 am

Regarding Negative point & floating point comparisions

Post by sampath »

Hi All,
I am developing an os in C for based on x86 arch. I have done my
booting code and switch to PM mode. Once the control comes to kernel
when I try to declare float or signed int with negative value and then
use compare statements it's giving wrong results. Some times it skips
the comparison part itself.

Some body pass on some clue to resolve this issue...


Tx,
Sampath S
User avatar
XCHG
Member
Member
Posts: 416
Joined: Sat Nov 25, 2006 3:55 am
Location: Wisconsin
Contact:

Post by XCHG »

Are you sure the FPU is initialized? use the FINIT instruction in order to initialize the FPU.
On the field with sword and shield amidst the din of dying of men's wails. War is waged and the battle will rage until only the righteous prevails.
sampath
Posts: 18
Joined: Wed Dec 20, 2006 4:00 am

Post by sampath »

No I have not done Initialization. Do I need to do FINIT explicitly???can i do it after switching to PM mode.???
User avatar
mystran
Member
Member
Posts: 670
Joined: Thu Mar 08, 2007 11:08 am

Post by mystran »

You can init the FPU whenever you please. But if negative signed integers are giving you wrong results, then there's something more wrong than just uninitialized floating point unit, because integers are integers whether they are signed or not, and should work correctly with or without an FPU installed (ofcourse anything post-386 always has FPU but still).

Could you give an example where signed integer comparison gives you wrong results?
The real problem with goto is not with the control transfer, but with environments. Properly tail-recursive closures get both right.
User avatar
Solar
Member
Member
Posts: 7615
Joined: Thu Nov 16, 2006 12:01 pm
Location: Germany
Contact:

Post by Solar »

And check whether it's perhaps your print function not being able to print the results correctly...
Every good solution is obvious once you've found it.
Post Reply