Sure especially in programming. Generally an int can be passed directly into a float.
Examples:
9 is an integer
9.00 is a float
in programming
int A = 9;
Float B = A;
Chat with our AI personalities
Most (all?) programming languages support automatic built-in conversion of this type, at the loss of the factional part. Following is a simple example in C:
void example(float f) {
int i = f;
...
}
If you call example(3.1415), i will have value 3.
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
The switch/case statement in the c language is defined by the language specification to use an int value, so you can not use a float value. You can, however, convert the float into an int and use it, so long as the resulting values and functionality meet your functional requirements.
A float is basically any number that isn't an integer, so it's basically a number with a decimal place.
atoi
The INT function is to convert something into an integer. An integer is a number that goes out two decimal places.