answersLogoWhite

0


Best Answer

THIS IS FOR JAVA i don't know about anything about other languages yes it can be assigned

the syntax is:

int (number) = (float) number

FOR EXAMPLE:

int = a;

a = (float ) 5.5;

if the (float) is not there then in Java it gives an error saying precision loss of data type

User Avatar

Wiki User

14y ago
This answer is:
User Avatar
More answers
User Avatar

Wiki User

12y ago

Yes, but you will lose precision. Most compilers will warn you about this unless you explicitly typecast.

double a;

float b;

b = a; // warning

b = (float) a; // no warning

This answer is:
User Avatar

User Avatar

Wiki User

13y ago

No, but a double value can be assigned to a float variable. (You will lose from the precision, obviously.)

This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Can a double value be assigned to float variable?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Engineering

Can an float value be assigned to int variable?

Yes, an integer can be assigned as a float value.But it get stored as a float value, that is an implicit type conversion occurs during compilation.Smaller data types are convertible to larger data types.eg:float b=12;// an integer constant is assigned to a float variableprintf("%f",b);// when printing b it will print as 12.000000


When function returns a value the entire function call can be assigned a variable?

AnswerYes, it can. For instance, if your function returns double you can assign the function call to a variable of type double.AnswerNo, only the returned value, of course.


How do you invoke function result () takes two float argument and returns an integer in c plus plus program?

You can do this by creating a forwarddeclaration of the function. You can call the forward drclared function inside the main to use it.int result(float num1, float num2);intmain(void){int value = result(3.14, 2.74);return (0);}intresult(float num1, float num2){int value = 0;// function codes goes here// you can alter the value of variable 'value'return (value);}The returning value of the 'result()' function is assigned to variable 'value' in 'main()'.


What value is assigned to extern variable?

Default initial value of extern integral type variable is zero otherwise null.


What error occurs when a real value is attempted to be assigned to an integer variable?

real value neededA compile time error i.e ..Error: possible loss of precision: double, required: intNone, it will converted automagically.

Related questions

Can an float value be assigned to int variable?

Yes, an integer can be assigned as a float value.But it get stored as a float value, that is an implicit type conversion occurs during compilation.Smaller data types are convertible to larger data types.eg:float b=12;// an integer constant is assigned to a float variableprintf("%f",b);// when printing b it will print as 12.000000


When you assign the value 5.628 into a float variable how can you avoid getting the decimal truncation warning?

When assigning a literal value, such as 5.628, to a float variable, you can avoid the decimal truncation warning by either using the float form of the constant (float var = 5.628f), typecasting the assignment (float var = (float) 5.628), or by making the variable double (double var = 5.628).


When function returns a value the entire function call can be assigned a variable?

AnswerYes, it can. For instance, if your function returns double you can assign the function call to a variable of type double.AnswerNo, only the returned value, of course.


How do you invoke function result () takes two float argument and returns an integer in c plus plus program?

You can do this by creating a forwarddeclaration of the function. You can call the forward drclared function inside the main to use it.int result(float num1, float num2);intmain(void){int value = result(3.14, 2.74);return (0);}intresult(float num1, float num2){int value = 0;// function codes goes here// you can alter the value of variable 'value'return (value);}The returning value of the 'result()' function is assigned to variable 'value' in 'main()'.


What is used as placeholder for an assigned value in a computer memory?

Variable


How do you use define in C?

Just type declare then the variable that you desire to assigned a certain constant value on it. Just type declare then the variable that you desire to assigned a certain constant value on it.


What is an expression with one variable?

3x+2 x is a variable. A variable is a symbol (x, y, etc...) that does not have an assigned value.


What is the constant of the variable?

The definition of constant variable is a variable whose value cannot be changed once it has been assigned a value for an experiment. It is the variable held steady, or constant, for a specific experiment.


What are real constants in java?

"real" numbers, in any programming language, are actually approximations of what is called a "real number" in math. Basically, a number that can handle decimals - but unlike the actual real numbers, of limited precision. In Java, the "real" data types are float, and double. double has greater precision. A "constant" in Java is similar to a variable, but its value can't be changed after it has been assigned a value.


What Is similar to a variable except it can be assigned a value only once?

A constant.


How do you declare a variable with initial value of 20.1234?

float myVariable = 20.1234;


What is the decimal value of the letter u?

None. A letter has no numerical value unless it represents a variable and a value is assigned to it.