Staredit Network

Staredit Network -> Miscellaneous -> Beginner's Question on Programming (C++)
Report, edit, etc...Posted by Screwed on 2005-01-09 at 21:02:09
Question: What is a floating point and how and when is it used?

I'm just a very new beginner, all answers can be (and wish to be) as detailed as possible.

Brief History
I just started reading a book on C ++ a few days ago. I was dertermind to learn C ++. I dunno if C ++ is the right place for me to start.. but anyway... I just came across something called floating point and it was explained in my home language. It was rather confusing so I read it over and over again. However I don't get it.


I'll just say what I know rite now. (which might not be right, correct me if I'm wrong)
Well... because we use fixed amount of bits to save values, only a small range can be correctly presented so when it comes to decimal or extremely large or small values, we use a expression called floating point. It said it is something similar to our commonly used scientifict notation. Using exponent and mantissa.

The example the in the book used the speed of light. (my crappy translation is below)

Vc (velocity of speed of light) = 299,800,000. m/sec = 2.998 x 10^8 m/sec.

In binary system, using 32 bit (4-byte) as example... the actual number is divided into two sections: (Also the part I don't get... why divide? and where do you divide it?)
- The mantissa section of the 24 bit.
- The exponent section of the 8 bit.

The value of the mantissa is between -1.0 and +1.0 (Q: how did you get this outcome? .. i mean.. how did the mantissa section of '24 bit' suddenly became -1.0 to 1.0?), and the exponent value is between -128 and 127. (I kind of got this part because in base 2 number system, 2^8 = 256 outcomes (combinations) and after considering also the negative outcomes it became -128 to 127 (including 0) which adds up to 256 combinations.

For this example in 32 bit's binary system, the exponent is 9 and the mantissa is 0.2998. (exponent 9 is value between -128 to 127 and mantissa 0.2998 is the value between -1.0 to 1.0 - that right?)

After all that, it would be great if someone could answer the 'floating point' to me as a full. The above is just an example of what I am talking about.

*Roughly Proof Read*
Report, edit, etc...Posted by DT_Battlekruser on 2005-01-09 at 23:43:09
A floating point variable is a number with things after a decimal point, instead of an integer, which doesn't have things after the decimal point.

Rest of story: T3h Huhzzors? confused.gif
Report, edit, etc...Posted by illusion(SS) on 2005-01-10 at 00:45:54
hummm...
where'd you get the book? biggrin.gif biggrin.gif
i want to learn too
Report, edit, etc...Posted by RexyRex on 2005-01-10 at 00:51:17
From my PHP book:

String - strings of spaces, text and numeric characters specified within double quotes ("...") or within single quotes ('...')
Integer - whole numbers without decimal places, such as 1,000
Floating-point - numbers that do have decimal places, like 3.142
Boolean - a truth value expressed with the case-insensitive PHP keywords of TRUE or FALSE.
Report, edit, etc...Posted by DT_Battlekruser on 2005-01-10 at 01:01:43
Note: These terms are by no means language specific.
Report, edit, etc...Posted by illusion(SS) on 2005-01-11 at 18:37:55
hmmm rexy... whered you get the php book? tongue.gif
Report, edit, etc...Posted by Screwed on 2005-01-11 at 23:20:19
Thanks people, that explains quite a bit biggrin.gif

QUOTE(illusion(SS) @ Jan 10 2005, 12:45 AM)
hummm...
where'd you get the book?  biggrin.gif  biggrin.gif
i want to learn too
[right][snapback]122366[/snapback][/right]


If you're in USA, you'll probably need to fly 12 hours to get to the place where I bought the book. tongue.gif

You can probably get it from most book shops. happy.gif
Report, edit, etc...Posted by illusion(SS) on 2005-01-12 at 22:12:05
12 HOURS!?!?!??! uh... whats the name of it?
Next Page (1)