Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

walkingcarcass

Tricky floating-point fudging

This topic is 5648 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

There is an instruction to calculate the remainder (FPREM) of a number eg 1983.652%83.43=23 because 1983.652%83.43=23*83.43+64.762 Trouble is it''s even slower than division. Suppose I wanted to do it on nice numbers eg 17.74%16=1.74 ie find A%(2^B)=? By shifting -1 by B and then shifting it some more, simply ANDing this result with the stored floating-point number should give the answer a good ten or twenty times quicker. Basically, truncate the mantissa. I can work it out on paper but the big-endian and little-endian guff and floating-point representation is doing my head in. Can anyone simplify the problem, or point to someone who''s already done it? Thanks. ******** A Problem Worthy of Attack Proves It''s Worth by Fighting Back

Share this post


Link to post
Share on other sites
Advertisement
you can try multiplying the float by a large value, say 1,000,000 and cast it to a LARGE_INTEGER.

You can then use iteger divides, getting fast remainders, etc...

then when you are done, cast it to a double and divide by 1000000.

Sometimes I need to do crap like this to fix up some of my whacky code... its messy lol!

www.cppnow.com

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!