Get the decimal part from a double

88

I want to receive the number after the decimal dot in the form of an integer. For example, only 05 from 1.05 or from 2.50 only 50 not 0.50

This question is tagged with c# .net

~ Asked on 2012-10-23 20:13:46

The Best Answer is


204

the best of the best way is:

var floatNumber = 12.5523;

var x = floatNumber - Math.Truncate(floatNumber);

result you can convert however you like

~ Answered on 2014-09-03 10:23:59


81

var decPlaces = (int)(((decimal)number % 1) * 100);

This presumes your number only has two decimal places.

~ Answered on 2012-10-23 20:16:21


Most Viewed Questions: