Separate Float into Integer and Fractional Parts
Posted on 2011-03-22
I need to separate a floating point decimal into 2 integers, one that represents the whole number part, and one that represents the factional part. For example, if the float is 10.25, I need to get 10 and 25.
The first part is easy, CONVERT(INT, [floating number])
However, I can't figure out the fractional part because there can be any number of digits after the decimal.
Both [floating number]%(CONVERT(INT, [floating number])) and [floating number] - (CONVERT(INT, [floating number])) will remove the whole number part, leaving me with 0.25 in my example. My challenge is scaling 0.25 up to 25, without knowing that there are only 2 digits after the decimal.
I hope that's not too repetitive. Any help would be much appreciated. Thanks.