- #1
Silicon Waffle
- 160
- 203
Hi, my C++ course has started since last week and I am learning basic input and output.
In my simple project, I have a function that will return a double number like this
The input is 12345 and the return value after the code is executed is 1234.500000
I find it strange as to why 0's are added unexpectedly.
I create a console application and test again with main like this
But the result becomes 1234.5 which is correct.
Another case I run with my function is if I input e.g 1234567890 then I expect the result should be 123456789.0 (I don't want the compiler to automatically delete my 0 after the decimal point). How can I achieve this ? Thank you a lot.
In my simple project, I have a function that will return a double number like this
Code:
double getLong(long long ll)
{
return ll/10.00;
}
The input is 12345 and the return value after the code is executed is 1234.500000
I find it strange as to why 0's are added unexpectedly.
I create a console application and test again with main like this
Code:
int main()
{
cout<<12345/10.00;
}
Another case I run with my function is if I input e.g 1234567890 then I expect the result should be 123456789.0 (I don't want the compiler to automatically delete my 0 after the decimal point). How can I achieve this ? Thank you a lot.