HP Forums

Full Version: Numworks - Question about frac()
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello,
in the office I use the calculators HP48sx, HP19b and another Casio 4000p (fits so nice in the shirt pocket).

HP48sx:
Input: "4.15" [FP] Display: "0.15"
Input: "-3.95" [FP] Display: "-0.95"

now I accidentally made the input with my seldom used Numworks:

Input: "frac(4.15)" Display: "0.15"
Input: "frac(-3.95)" Display: "0.05"

are FP and frac() 2 different commands?
I am confused.

(Please don't hit me right away, I only had 2 years of math (algebra) as an elective in school).

Thank you
Obviously, the implementations differ for negative arguments. Unfortunately, I'm unfamiliar with C, but who is, may have a look at the source of Numwork's frac here.

I guess Numwork uses floor C function, which gives -4 when applied to -3.95, and if you subtract -4 from -3.95, you are given 0.05?

Also I guess HP is simply truncating what's on the left hand side of the decimal point, so -0.95 is remaining. HP code aficionados know better for sure.

At the end of the day, mathematically speaking 0.05 and -0.95 are the same modulo 1. :-)
addendum:

i have in the meantime entered the examples into WolframAlpha, etc:
always the same result; only Numworks differs

WolframAlpha:
Input: "frac(4.15)" Display: "0.15"
Input: "frac(-3.95)" Display: "-0,95"
Bonjour à toutes et tous,

As a French company based in Paris, Numworks mainly targets the French market and its calculator is particularly suitable for the intended use in our schools.

Therefore, the function \( frac(x) \) corresponds to the definition of the fractional part of the number x and should not be confused with the function giving the decimal part of a number.

Therefore, for any real \(x\), positive or negative, its definition corresponds to \( frac(x)= x - \left \lfloor x\right \rfloor \)

The fractional part of the number \(x\) is therefore always a positive number and is zero only when x is an integer.

For negative real numbers \(x\), \( frac(x) \) will therefore be positive and corresponds to the 1's complement of the decimal part of the number \(x\).


Par exemple:
\( \begin{matrix}frac(-3,85)&=&(-3,85)&-&\left\lfloor-3,85\right\rfloor\\&=&(-3,85)&-&(-4)\\&=&(-3,85)&+&4\\&=&4&-&3,85\\&=&0,15\\\end{matrix} \)



In English, frac(x) can designate the decimal part of a number, which explains why sites corresponding to other standards give a different result.

Hope, this help a bit.
C.Ret
@ C.Ret, your explanation helped me.

Conclusion:
the function frac(x) has a different definition in France than in the (probably!) rest of the world.

Many thanks

(translated with google)
(03-03-2023 11:25 PM)Pälzer Wrote: [ -> ]Conclusion:
the function frac(x) has a different definition in France than in the (probably!) rest of the world.

Unfortunately it’s another exemple where there is not a universal consensus on the definition of a mathematical notion, and it’s not specific to France.

From Wolfram Mathworld:
Quote: Although Spanier and Oldham (1987) use the same definition as the Wolfram Language, they mention the formula only very briefly and then say it will not be used further. Graham et al. (1994, p. 70), and perhaps most other mathematicians, use the different definition

\( frac(x)= x - \left \lfloor x\right \rfloor \)
Reference URL's