Public Group

Float object to integer world possible?

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

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 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.

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 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]

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.

1. 1
2. 2
Rutin
22
3. 3
A4L
15
4. 4
5. 5
khawk
14

• 13
• 26
• 10
• 11
• 44
• Forum Statistics

• Total Topics
633742
• Total Posts
3013639
×