gbadev.org forum archive

This is a read-only mirror of the content originally found on forum.gbadev.org (now offline), salvaged from Wayback machine copies. A new forum can be found here.

C/C++ > Q:Rounding off floats and setting title in mutliboot screen.

#11709 - Stormcrow - Thu Oct 16, 2003 11:25 am

Hi, I'm kinda new to this forum so I hope this hasn't been asked before. I checked the present topics but I couldn't find anything so here goes:

I haven't found any rounding off functions. I could make one if I knew how to get the fraction part of a float, but i don't know that either. Does anyone know how to do that? And is there perhaps a mathematical reference available, because I have no idea what a lot of functions in math.h do.

Another question: How do I set the title of a program in the mutliboot screen?

Thanks for helping.

#11712 - poslundc - Thu Oct 16, 2003 3:47 pm

Stormcrow wrote:
Hi, I'm kinda new to this forum so I hope this hasn't been asked before. I checked the present topics but I couldn't find anything so here goes:

I haven't found any rounding off functions. I could make one if I knew how to get the fraction part of a float, but i don't know that either. Does anyone know how to do that? And is there perhaps a mathematical reference available, because I have no idea what a lot of functions in math.h do.


Don't use floating point on the GBA. It is emulated in software and will be impossibly slow.

Learn how to do fixed-point arithmetic, then see this topic for instructions on how to round off fixed-point variables.

Sorry I can't help you out with your other queston, as I've never used multiboot.

Dan.

#11735 - Master S - Fri Oct 17, 2003 9:28 am

If you realy want to use use floats, it's real easy to round a float.

All you have to do is to add 0.5f before you store in a int

ex. 1.9 + 0.5 = 2.4 -> 2
1.4 + 0.5 = 1.9 -> 1

#11738 - Stormcrow - Fri Oct 17, 2003 4:21 pm

I totally forgot about that one. Indeed, just adding 0.5 before turning into an int works.

Thx!

Still, does anyone know how to change the title of a program shown at multiboot?

#11739 - niltsair - Fri Oct 17, 2003 4:50 pm

You need to either use a tool to edit the Rom Header or one of the file included for linking contain the name. (I think lnkscpt)
_________________
-Inside every large program is a small program struggling to get out. (Hoare's Law of Large Programs)
-The man who can smile when things go wrong has thought of someone he can blame it on. (Nixon's Theorem)

#11741 - yaustar - Fri Oct 17, 2003 6:12 pm

use FATv8 is probably the easiest one to use
_________________
[Blog] [Portfolio]