Assignment & Increment Operators | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Assignment & Increment Operators

/* When I input integers it outputs integers. However, when I input a decimal(ex:23.2) it outputs it with an extra "0" (ex:2320). I don't get the reason behind this. I started learning today. Please help. */ double x = 10; Console.WriteLine("Enter a number:"); double z = Convert.ToDouble(Console.ReadLine()); x *= z; Console.WriteLine(x)

14th Nov 2016, 3:28 PM
Harold Finch
1 Answer
+ 2
All variable types reserve a specific amount of bits for their variables. So if your saved number isn't that big that it can fill all bits, it's padded with 0s
14th Nov 2016, 6:27 PM
Arsal Ali
Arsal Ali - avatar