Jump to content

  • Log In with Google      Sign In   
  • Create Account

FREE SOFTWARE GIVEAWAY

We have 4 x Pro Licences (valued at $59 each) for 2d modular animation software Spriter to give away in this Thursday's GDNet Direct email newsletter.


Read more in this forum topic or make sure you're signed up (from the right-hand sidebar on the homepage) and read Thursday's newsletter to get in the running!


ceil replacement


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
4 replies to this topic

#1 digiman   Members   -  Reputation: 122

Like
Likes
Like

Posted 08 August 2001 - 03:19 AM

I''m working on a total math.h library replacement for my engine. I have almost all functions very nicely except for ceil. It doesn''t seem to work always correctly. Does anybody know where can I get additional info about it? Or just a piece of code?

Sponsor:

#2 wings656   Members   -  Reputation: 122

Like
Likes
Like

Posted 08 August 2001 - 09:08 AM

This is a simple way of rounding up:

int ceil(float f){
int i;
f+=1.0;
i=f;
return i;
}

I haven''t tried it out, but it should work

Jamie--wings656@hotmail.com

#3 digiman   Members   -  Reputation: 122

Like
Likes
Like

Posted 08 August 2001 - 09:56 AM

That''s slow... Converting from float to int and back... There must be another solution

#4 johnb   Members   -  Reputation: 347

Like
Likes
Like

Posted 08 August 2001 - 09:00 PM

> That''s slow... Converting from float to int and back... There
> must be another solution

I think Jamie''s solution is the quickest on most processors. The only caveat is if you code it in C you are letting the compiler choose how to convert to float to int, and it may substiture it''s own lib call or other inefficient code. If you know the processor well you can often do better if you code it in assembly yourself. For maximum speed look at using inline assembly, though this is very processor/compiler dependent.

#5 digiman   Members   -  Reputation: 122

Like
Likes
Like

Posted 09 August 2001 - 07:34 AM

ok, thanx!




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS