WolframAlpha function that returns the 'decimal' part of a number

1k Views Asked by At

Is there a function or command in Wolfram Alpha for getting only the decimal part of a number?

Something like this: DecimalPart(3.4231) = 0.4231

I will be using this for calculations of very large numbers.

Thank you for your time.

3

There are 3 best solutions below

0
On BEST ANSWER

You can use the fractional part function frac().

NB there are actually three different functions sometimes called the fractional part. All three agree at nonnegative real and negative integral arguments, but in general they differ for negative nonintegral arguments. Their implementations in W.A. are (along with suggestive examples):

  • frac(x): frac(-1/3) returns $-\tfrac{1}{3}$
  • x - floor(x): (-1/3) - floor(-1/3) returns $\tfrac{2}{3}$
  • abs(frac(x)): abs(frac(-1/3)) returns $\tfrac{1}{3}$

See the Wikipedia article Fractional part for details.

7
On

For positive numbers, you can always do $x-\text{floor}(x)$.

0
On

This is called fractional part: $\text{frac}[x]$. See here for an example.