Skip to content
Prev 325794 / 398513 Next

Built-in function for extracting mantissa and exponent of a numeric

On 23/06/2013 10:54, S?ren H?jsgaard wrote:
No, because that is not how the number is stored (and in fact the value 
stored is a binary fraction with a slightly different value).
format() is doing a lot of work to produce a decimal approximation to 
'x', including choosing the precision.

It is not clear what you want: if you merely want to express x as a*10^b 
for 1 <= a < 10 then

b <- floor(log10(x))
a <- x/10^b

does the job (but might get values of a very slightly less than 1 or 
above 10, so if you care this might need checking and refinement).