Confused with variable types

Sep 13, 2010 at 1:08am
Ive come across a variable named float which has a range of 3.4E to 38.

I understand that its for floating point devision numbers.

But i dont understand the range numbers, what does the letter "E" mean or represent after the 3.4 number?

Im new to programming btw

Thanks :)
Sep 13, 2010 at 1:10am
that's scientific notation and isn't really specific to programming. It's more of a mathematical thing.

3.4e38 is 3.4 * 10^38 or 340000000000 ... (37 zeros)
Sep 13, 2010 at 1:12am
ermm ok....

can you tell me in words whats going on there?
Sep 13, 2010 at 1:30am
Its a way to separate the digits of a number from their magnitude in 'powers of ten'. Instead of writing down bunches of zeros all the time mathematicians came up with a short hand notation where they just write the number of zeros down rather than the zeros themselves.

So instead of writing 100000000 I can just say 1x108

That works because 108 = 10x10x10x10x10x10x10x10 = 100000000
Last edited on Sep 13, 2010 at 1:31am
Sep 13, 2010 at 1:42am
ok thanks, i kinda get that, but im just wondering, what actual word the "e" short for, is it short for a word, or is "e" just "e" on its own :)
Sep 13, 2010 at 1:49am
It is short for 'exponent'.

1.2e4 is the same as 1.2x104 is the same as 12000.

Hope this helps.
Sep 13, 2010 at 1:58am
thanks for all the replies, its coming clearer :)

its confusing me because in my book ive got it says:

type: float values: 3.4e +/- 38 (seven significant digits)
Sep 13, 2010 at 2:59am
that's saying the largest number is 3.4e38 and the smallest (nonzero) number is 3.4e-38

negative exponents are the same thing. 1.2e-4 is the same as 1.2x10-4 is the same as 0.00012
Sep 13, 2010 at 9:40am
Thanks alot
Sep 13, 2010 at 9:47am
oh, one last thing, what does the"(seven significant digits)" mean
Sep 13, 2010 at 2:36pm
It means that while numbers can be very large or very small, they can only have 7 (nonzero) digits.

For example the number 76543210000000 probably could be represented, but the number 11111111111111 probably couldn't be.

Even though 111... is smaller than 765.... it has more significant digits.
Sep 14, 2010 at 11:31am
ok, so because the value of float is 3.4e +/- 38, does this mean this is correct:

the largest number is:

340000000000000000000000000000000000000 (37 zeros)

and the smallest number is:

00000000000000000000000000000000000000.34 (37 zeros)

are floating point numbers just numbers with decimal places, which are used for precise variables?
Sep 14, 2010 at 1:41pm
Almost! Watch where you put your points :-)

0.000000000000000000000000000000000000034 (37 zeros)
not
00000000000000000000000000000000000000.34 (37 zeros)

floats will probably do you for most purposes. If you really need something more precise then use a double (which has a greater range)
http://www.cplusplus.com/doc/tutorial/variables/
Sep 14, 2010 at 8:04pm
oh yh lol

Thanks
Topic archived. No new replies allowed.