# Thread: I don't understand what the difference is between a float and a double

1. Member
Join Date
Oct 2012
Posts
50
Rep Power
0

## I don't understand what the difference is between a float and a double

Whenever I look this up, the explanation I get seems to be convoluted to me, and I can't get a simple straight answer. So, to be more specific, could someone explain to me, for example what the difference between double a = 2.25 and float a = 2.25f is? Also, when is it more appropriate to use a float over a double, and vice versa (I'm looking for specific examples if possible)?

Also, I don't know if this is related to this question or not, but how do you get a program to NOT truncate a zero at the end of a decimal. For example, I want to program to output 0.50 instead of 0.5

2. Member
Join Date
Sep 2012
Posts
70
Rep Power
0

## Re: I don't understand what the difference is between a float and a double

double can hold more numbers

float = 32-bit
double = 64-bit

with primitives you are limited in how much can be held because it reserves the space on the machine and doesn't change.

3. Member
Join Date
Oct 2012
Posts
50
Rep Power
0

## Re: I don't understand what the difference is between a float and a double

Originally Posted by killutch
double can hold more numbers

float = 32-bit
double = 64-bit

with primitives you are limited in how much can be held because it reserves the space on the machine and doesn't change.
I know that, but that doesn't really answer my question.

4. Member
Join Date
Jun 2012
Location
Remscheid, Germany
Posts
61
Rep Power
0

5. ## Re: I don't understand what the difference is between a float and a double

A double can for some values hold a more accurate representation than a float.

db

6. Member
Join Date
Oct 2012
Posts
50
Rep Power
0

## Re: I don't understand what the difference is between a float and a double

Originally Posted by psx2514
So, to be more specific, could someone explain to me, for example, what the difference between double a = 2.25 and float a = 2.25f is? Also, when is it more appropriate to use a float over a double, and vice versa (I'm looking for specific examples if possible)?

7. Member
Join Date
Jun 2012
Location
Remscheid, Germany
Posts
61
Rep Power
0

8. Member
Join Date
Sep 2012
Posts
70
Rep Power
0

## Re: I don't understand what the difference is between a float and a double

double a = 2.25 and float a = 2.25f

in this example the value is the same. There is no difference accept the double takes up more space on the machine and each might have to be handled a little differently depending on the situation with type casting and what not.

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•