The result of subtracting the integer part of x from x I want to know what does this fo

arridsd9

arridsd9

Answered question

2022-06-14

The result of subtracting the integer part of x from x
I want to know what does this formula do with the integer x
frac ( x ) = x x ,   x >= 0
I've searched and found that this is called finding the fraction part of x
Can anyone explain it for me?

Answer & Explanation

Belen Bentley

Belen Bentley

Beginner2022-06-15Added 28 answers

First, look at
x
which finds the largest integer less than or equal to x. Some examples:
x x 3.2 3.0 1.999 1 0.5 0.0 4.0 4.0
Now let's subtract x from x:
x x x x 3.2 3.0 0.2 1.999 1 0.999 0.5 0.0 0.5 4.0 4.0 0.0
In short: for positive numbers, this expression is "the stuff to the right of the decimal point."
Extra credit: You might ask yourself why this doesn't work for negative numbers.
rigliztetbf

rigliztetbf

Beginner2022-06-16Added 7 answers

The 'floor' function ( ), returns the largest integer value which is less than (or equal to) the argument which was provided.
For example:
4 = 4.5 = 4
The function you created 'frac' is the difference of the argument, and it's integer part, so that you are basically returning the fractional remainder

Do you have a similar question?

Recalculate according to your conditions!

Ask your question.
Get an expert answer.

Let our experts help you. Answer in as fast as 15 minutes.

Didn't find what you were looking for?