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 

PSP makes faults while rounding?!?

 
Post new topic   This topic is locked: you cannot edit posts or make replies.    forums.ps2dev.org Forum Index -> PSP Development
View previous topic :: View next topic  
Author Message
steffven



Joined: 19 May 2008
Posts: 28

PostPosted: Thu May 29, 2008 6:24 am    Post subject: PSP makes faults while rounding?!? Reply with quote

Code:
temp2 = ceil((temp / 34));
printf("%d | %d", temp2, temp);

It prints out "0 | 13", "1 | 13" would be right.
Another time it prints out "1 | 45", "2 | 45" would be right.

Does somebody know where my fault is?
Back to top
View user's profile Send private message
cyberfish



Joined: 19 May 2008
Posts: 19

PostPosted: Thu May 29, 2008 6:35 am    Post subject: Reply with quote

C/C++ integer division doesn't round. It truncates.

So it becomes essentially
Code:

temp2 = ceil((0));
printf("%d | %d", temp2, temp);


Assuming temp is an integer.
Back to top
View user's profile Send private message
bullcrap0



Joined: 17 Apr 2008
Posts: 3

PostPosted: Thu May 29, 2008 9:46 am    Post subject: Reply with quote

check this out http://codepad.org/R5CZ4sc0

EDIT: I hope you notice the 34. <- that's 34DOT
Or you could just type 34.0
Back to top
View user's profile Send private message
jbit
Site Admin


Joined: 28 May 2005
Posts: 293
Location: København, Danmark

PostPosted: Thu May 29, 2008 5:34 pm    Post subject: Reply with quote

Please keep this forum PSP related
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   This topic is locked: you cannot edit posts or make replies.    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