# allow decimals

This is a discussion on allow decimals within the C++ Programming forums, part of the General Programming Boards category; when I use "int" it doesnt allow decimals. What allows decimals?. Also lets say I make an integer called x, ...

1. ## allow decimals

when I use "int" it doesnt allow decimals. What allows decimals?. Also lets say I make an integer called x, a and b, and I want x to be a*b what should I do?

2. In C++ the default type for decimal numbers is double, so use double instead of int.

To assign the value of a*b to x, you do just that, assign a*b to x. If you know what the operator for assignment is in C++, that will help.

3. >when I use "int" it doesnt allow decimals.
That's because the int type stores an integer, which doesn't support precision. You want a real number, or floating-point, supported by the float, double, and long double types.

>Also lets say I make an integer called x, a and b, and I want x to be a*b what should I do?
First you should get a book on C++. Then you should read it.

4. If you don't know a float or double in C++, you really need to take a course, look at this site's tutorials, or buy a book. And to answer your question about multiplying, use these lines of code:
Code:
```double a = 1.5;
double b = 3.45;
double x = a*b;```