PSP makes faults while rounding?!?

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

Moderators: cheriff, TyRaNiD

Locked
steffven
Posts: 28
Joined: Mon May 19, 2008 7:37 pm

PSP makes faults while rounding?!?

Post by steffven »

Code: Select all

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?
cyberfish
Posts: 19
Joined: Mon May 19, 2008 3:39 pm

Post by cyberfish »

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

So it becomes essentially

Code: Select all

temp2 = ceil((0));
printf("%d | %d", temp2, temp);
Assuming temp is an integer.
bullcrap0
Posts: 3
Joined: Thu Apr 17, 2008 10:32 am

Post by bullcrap0 »

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

EDIT: I hope you notice the 34. <- that's 34DOT
Or you could just type 34.0
User avatar
jbit
Site Admin
Posts: 293
Joined: Sat May 28, 2005 3:11 am
Location: København, Danmark
Contact:

Post by jbit »

Please keep this forum PSP related
Locked