Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Int to Decimal Conversion - Insert decimal point at specified location

I have the following int 7122960
I need to convert it to 71229.60

Any ideas on how to convert the int into a decimal and insert the decimal point in the correct location?

like image 740
Baxter Avatar asked Apr 06 '12 14:04

Baxter


People also ask

How do you convert int to decimal?

To convert binary integer to decimal, start from the left. Take your current total, multiply it by two and add the current digit. Continue until there are no more digits left.

How do you convert an int to a decimal in C++?

cout<<"Binary form of "<<num<<" is "; for (int j = i - 1; j >= 0; j--) cout << binaryNumber[j]; In the function, BinaryToDecimal(), a while loop is used to convert the binary number into decimal number. The LastDigit contains the last bit of the temp variable. The base contains the base value such as 2, 4, 6, 8 etc.

How do you convert int to decimal in Python?

In Python, you can simply use the bin() function to convert from a decimal value to its corresponding binary value. And similarly, the int() function to convert a binary to its decimal value. The int() function takes as second argument the base of the number to be converted, which is 2 in case of binary numbers.

How do I cast an object to a decimal in C#?

ushort[] numbers = { UInt16. MinValue, 121, 12345, UInt16. MaxValue }; decimal result; foreach (ushort number in numbers) { result = Convert. ToDecimal(number); Console.


1 Answers

int i = 7122960; decimal d = (decimal)i / 100; 
like image 52
Bala R Avatar answered Sep 27 '22 17:09

Bala R