Float variable in kernel mode?

Discuss the development of new homebrew software, tools and libraries.

Moderators: cheriff, TyRaNiD

Post Reply
pspflashsystem
Posts: 31
Joined: Mon Mar 24, 2008 12:31 am

Float variable in kernel mode?

Post by pspflashsystem »

Hi everybody,

I want to know why when my prx is in kernel mode float variable doesn't work anymore. Indeed, when I use blit.c with:

Code: Select all

float psp = 5.648;
sprintf(table, "%f", psp);
I can only see the character string "f" instead of 5.648 :S

In user mode there's no problem with float

Thanks in advance :)
I'm apologize for my bad English because I am French :)

.::pspflashsystem::.
J.F.
Posts: 2906
Joined: Sun Feb 22, 2004 11:41 am

Post by J.F. »

The kernel mode c lib is rather limited on what it supports. Printf formatting is not one of the things you can do. You'll have to add extra code to do that formatting for you.
pspflashsystem
Posts: 31
Joined: Mon Mar 24, 2008 12:31 am

Post by pspflashsystem »

Well thanks JF for this information but how I can do the same type of thing like this variable?
Best regards.
I'm apologize for my bad English because I am French :)

.::pspflashsystem::.
OldPrisoneR
Posts: 53
Joined: Thu Mar 20, 2008 2:33 am

Post by OldPrisoneR »

pspflashsystem wrote:but how I can do the same type of thing like this variable?
Best regards.
f.e. this tricky way

Code: Select all

    #define PRECISION 1000
    #define f(a) (int)((a-(int)a)*PRECISION)
    #define i(a) (int)(a)  
    float fl = 5.456;
    printf("%d.%d\n",i(fl),f(fl));
LOL
J.F.
Posts: 2906
Joined: Sun Feb 22, 2004 11:41 am

Post by J.F. »

I don't think you get ANY formatting... you'll have to swipe the code from one of the foss implementations. I remember this from a test I did a year or so back, and it's not just floats. I'll have to check my old archives to see if I still have that, but I had to swipe some BSD formatting code to make the string to print.
pspflashsystem
Posts: 31
Joined: Mon Mar 24, 2008 12:31 am

Post by pspflashsystem »

Thanks a lot oldprisoner and JF:
I will wait JF for your archives :)
Thanks again

EDIT : It works fine thanks oldprisoner :)
I'm apologize for my bad English because I am French :)

.::pspflashsystem::.
pspflashsystem
Posts: 31
Joined: Mon Mar 24, 2008 12:31 am

Post by pspflashsystem »

OldPrisoneR---->>> if I want to display "0.0030" it displays only "0.30" but I want to display "0.0030"

Thanks for your help

EDIT: I find how I can do it thanks again ;)
I'm apologize for my bad English because I am French :)

.::pspflashsystem::.
Post Reply