forums.ps2dev.org Forum Index forums.ps2dev.org
Homebrew PS2, PSP & PS3 Development Discussions
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Float variable in kernel mode?

 
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development
View previous topic :: View next topic  
Author Message
pspflashsystem



Joined: 24 Mar 2008
Posts: 31

PostPosted: Sun Nov 09, 2008 5:21 am    Post subject: Float variable in kernel mode? Reply with quote

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:
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::.
Back to top
View user's profile Send private message
J.F.



Joined: 22 Feb 2004
Posts: 2906

PostPosted: Sun Nov 09, 2008 8:41 am    Post subject: Reply with quote

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.
Back to top
View user's profile Send private message AIM Address
pspflashsystem



Joined: 24 Mar 2008
Posts: 31

PostPosted: Tue Nov 11, 2008 7:36 am    Post subject: Reply with quote

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::.
Back to top
View user's profile Send private message
OldPrisoneR



Joined: 20 Mar 2008
Posts: 53

PostPosted: Tue Nov 11, 2008 8:22 am    Post subject: Reply with quote

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

f.e. this tricky way
Code:
    #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
Back to top
View user's profile Send private message
J.F.



Joined: 22 Feb 2004
Posts: 2906

PostPosted: Tue Nov 11, 2008 8:42 am    Post subject: Reply with quote

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.
Back to top
View user's profile Send private message AIM Address
pspflashsystem



Joined: 24 Mar 2008
Posts: 31

PostPosted: Tue Nov 11, 2008 8:55 pm    Post subject: Reply with quote

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::.
Back to top
View user's profile Send private message
pspflashsystem



Joined: 24 Mar 2008
Posts: 31

PostPosted: Sat Nov 15, 2008 6:06 am    Post subject: Reply with quote

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::.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development All times are GMT + 10 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group