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.
I'm using a double in my kernel code, and I need to convert it to an int. The standard type-casting does not seem to work (or am I wrong?). How do I convert a double into an int (I want to remove the fraction part). Or perhaps someone knows how else I could improve the following code:
1. You can avoid all the doubles by rearrange the arithmetic with integer operations.
2. Since you're running your own kernel, chances is that FPU is not initialized yet. Try FINIT to put it in good state. (note that I'd never used double in my kernel so I'm not so sure on this).
The standard type-casting does not seem to work (or am I wrong?)
How it does not work? can't compile, link, calculate wrong values, or it reset the CPU upon execute?
bluemoon wrote:1. You can avoid all the doubles by rearrange the arithmetic with integer operations.
2. Since you're running your own kernel, chances is that FPU is not initialized yet. Try FINIT to put it in good state. (note that I'd never used double in my kernel so I'm not so sure on this).
The standard type-casting does not seem to work (or am I wrong?)
How it does not work? can't compile, link, calculate wrong values, or it reset the CPU upon execute?
Well, maybe the doubles work, but then why do all the magenta bars appear away from the background bar? Is there something wrong with my code? It appears to work when I directly pass an int to the splash_draw_bar() function.
Because there's obviously something wrong with it. When I put 20 it appears above the "Atom loading..." message. Which is weird. Maybe it's got something to do with the error anyway?
You seem to be using the bar width where you should be using the screen width (pitch) - those are two different numbers.
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
And if I were you I'd like to control if x and y are values in the range, and I'd also add an empty char because if the screen is already filled you will see some colored text.