117k views
3 votes
How can I convert a number that is a double to a long?

User Szer
by
7.8k points

1 Answer

5 votes

Step-by-step explanation:

double data type contains: 8 bytes

long data type contains: 8 bytes

We can convert double to a long using Type casting.

When we want to convert from one data type to another data type we use Type Casting. For example, if we want to store a lengthy value(double,long) in a integer, we can type int (data type)Variable . Using the cast operator, you can explicitly convert values from one type to another. In c language, there are two kinds of type casting that are Implicit conversions and Explicit Conversions.

Example-

double x = callingFunction();

// Now typecast

ing

long y = (long) x;

User Gregoltsov
by
7.8k points