Jump to content
• Advertisement

Public Group

# Float object to integer world possible?

This topic is 2873 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

Is it possible to model an object with a floating point coordinates for the vertices and transpose to an integer based world?

Barring that, what is the largest non-exponential number a floating point or double can represent? I've been looking over the internet, but haven't found anything. Looking at float.h, it says 6 digits of decimal precision. Does that mean up to 999,999 before it goes to exponential notation?

#### Share this post

##### Share on other sites
Advertisement
Yes, it is certainly possible to represent it that way.

In fact, there are many games that use fixed point instead of floating point. Basically it means that all numbers are divided by a constant, such as x/1024. The lower bits are the fractional part, the upper bits are the whole number. What you described is fundamentally no different than fixed point.

Next in your post, floating point numbers are ALWAYS an exponent. When it says you get six decimal digits of precision, it means you can precisely represent six digits. The decimal digits past that are imprecise. It can be 9.99999 or 0.000000999999 or 9999990000000, or other floating positions of the decimal point. You have a specific number of known digits and float the decimal point left or right as needed.

The error that starts at the sixth digit propagates, so when you use it enough you will find the fifth digit is in error, then the fourth, third, etc. You can read about it in a famous article titled "What every computer scientist should know about floating point numbers". GO read it.

#### Share this post

##### Share on other sites

Yes, it is certainly possible to represent it that way.

In fact, there are many games that use fixed point instead of floating point. Basically it means that all numbers are divided by a constant, such as x/1024. The lower bits are the fractional part, the upper bits are the whole number. What you described is fundamentally no different than fixed point.

Ok, I did look into fixed-point a few weeks back but wasn't sure. I'm a bit hesitant to ask such newbish questions.

Next in your post, floating point numbers are ALWAYS an exponent. When it says you get six decimal digits of precision, it means you can precisely represent six digits. The decimal digits past that are imprecise. It can be 9.99999 or 0.000000999999 or 9999990000000, or other floating positions of the decimal point. You have a specific number of known digits and float the decimal point left or right as needed.
[/quote]

When I ran some test code of assigning an int to a float and looked at the debugger, it seemed to maintain the base up to, but not including, 99,999,999. One more over and it went to 1E8 or so.

I worded this wrong. I think the term I needed to use was significand for what I called the base. The base would of course be base 10.

The error that starts at the sixth digit propagates, so when you use it enough you will find the fifth digit is in error, then the fourth, third, etc. You can read about it in a famous article titled "What every computer scientist should know about floating point numbers". GO read it.
[/quote]

Googled it up and I'll spend some time tonight reading it.

#### Share this post

##### Share on other sites

When I ran some test code of assigning an int to a float and looked at the debugger, it seemed to maintain the base up to, but not including, 99,999,999. One more over and it went to 1E8 or so.
That's just how the debugger chose to display it. There's no fundamental difference between how those values are stored.

It's just that a debugger doesn't want to for example display 1 trillion 234 billion as 1234000000000 when it can use a far shorter representation 1.234e12. It's not only shorter, but can be read quicker as you aren't left having to count the zeros.

#### Share this post

##### Share on other sites

• Advertisement
• ### Game Developer Survey

We are looking for qualified game developers to participate in a 10-minute online survey. Qualified participants will be offered a \$15 incentive for your time and insights. Click here to start!

• Advertisement

• ### Popular Now

• 15
• 11
• 9
• 11
• 15
• Advertisement
×

## Important Information

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

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!