MATH FUNCTIONS
Author Message
MATH FUNCTIONS

Trunc would return the integer part of the number.   Turns a real number
into an integer. So 3 and 27
Frac returns the fractional part of a number.  So .1416 and .1888
Int returns the whole number part and the result is a real number.  So 3.0
and 27.0

--
Patti Handwerk

Quote:

>Hi,

>I wish to know how work the functions

>Trunc(x)
>Int(x)
>Frac(x)

>...so I can adapt a Pascal program in C/C++
>What each function is suppose to return if
>X=3.1416 and
>X=-27.1888 for example.

>Thank you very much!

>JGR

Wed, 18 Jun 1902 08:00:00 GMT
MATH FUNCTIONS
Hi,

I wish to know how work the functions

Trunc(x)
Int(x)
Frac(x)

...so I can adapt a Pascal program in C/C++
What each function is suppose to return if
X=3.1416 and
X=-27.1888 for example.

Thank you very much!

JGR

Wed, 18 Jun 1902 08:00:00 GMT
MATH FUNCTIONS

Quote:

> Hi,

> I wish to know how work the functions

> Trunc(x)

truncates the number, ie you get the part prior to the "."
without rounding

-> 3, -27

Quote:
> Int(x)

rounds to the closest integer

-> 3, -27

Quote:
> Frac(x)

returns the fraction, ie the part after the "."

-> 0.1416, -0.1888 (this is my guess, I didn't test whether
it includes the minus)

Quote:
> ....so I can adapt a Pascal program in C/C++
> What each function is suppose to return if
> X=3.1416 and
> X=-27.1888 for example.

-Mike

Wed, 18 Jun 1902 08:00:00 GMT
MATH FUNCTIONS

Quote:

> > Hi,

> > I wish to know how work the functions

> > Trunc(x)

> truncates the number, ie you get the part prior to the "."
> without rounding

> -> 3, -27

> > Int(x)

> rounds to the closest integer

-INF!
Int(-3.1) = -4.0
Int(3.1) = 3.0
Int (-3.7) = -4.0
Int (-3.1) = 3.0
but isn't an integer at last. if you want to have an integer, you need
trunc(int(x))!

If you want to round to the closest integer, just use round!

- Show quoted text -

Quote:

> -> 3, -27

> > Frac(x)

> returns the fraction, ie the part after the "."

> -> 0.1416, -0.1888 (this is my guess, I didn't test whether
> it includes the minus)

> > ....so I can adapt a Pascal program in C/C++
> > What each function is suppose to return if
> > X=3.1416 and
> > X=-27.1888 for example.

>  -Mike

Wed, 18 Jun 1902 08:00:00 GMT

 Page 1 of 1 [ 4 post ]

Relevant Pages