answersLogoWhite

0


Best Answer

Some smart compilers will not allow you do that. If you managed to do that, there are couple different results, the most predictible is decimal part will be cut, only what left will be shown. If it exceed the amount of memory reserved for int (double > float > int), it will show the maximum or positive or negative value for int type, or it will shifted by some amount from the maximum or minimum.

User Avatar

Wiki User

13y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: What happens if you assign a number with a decimal to an integer?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Engineering

In many languages it is an error to assign a real number to an integer variable True or False?

true


Will the output of ADC be an integer or will it be a decimal also?

You will have to determine its scaling factor. The output of the ADC is a number, you can interpret it anyway that is necessary for the system it is in.


What is the INT functions?

The INT function is to convert something into an integer. An integer is a number that goes out two decimal places.


What is the formula that would get the tenths digit number in a three digit integer number?

In a three digit integer number the tenthsdigit is always 0 as integer numbers are whole numbers and have no decimal part and tenths are decimal parts:tenths_digit_of_integer_number = 0I suspect you mean "How to find the tens digit of an integer number?"; this is the second from the right, so:tens_digit = (INT(number ÷ 10)) MOD 10For example, in C this would become: tens_digit = (number / 10) % 10;


How do you write a Java program to convert a decimal number to an octal number?

public class Dataconversion { public static void main(String[] args) { System.out.println("Data types conversion example!"); int in = 44; System.out.println("Integer: " + in); //integer to binary String by = Integer.toBinaryString(in); System.out.println("Byte: " + by); //integer to hexadecimal String hex = Integer.toHexString(in); System.out.println("Hexa decimal: " + hex); //integer to octal String oct = Integer.toOctalString(in); System.out.println("Octal: " + oct); } }