Core Function Modf
From Sputnik Wiki
(Difference between revisions)
(Created page with "<pre> Modf( <x>, <intpart> ) </pre> === Description === Breaks x into an integral and a fractional part. The integer part is stored in the variable pointed by intpart, and the...") |
m (1 revision) |
||
(2 intermediate revisions by one user not shown) | |||
Line 35: | Line 35: | ||
my $param = 3.14159265; | my $param = 3.14159265; | ||
my $fractpart = modf ($param, $intpart); | my $fractpart = modf ($param, $intpart); | ||
− | + | printf ("%f = %f + %f \n", $param, $intpart, $fractpart); | |
// Prints: 3.141593 = 3.000000 + 0.141593 | // Prints: 3.141593 = 3.000000 + 0.141593 | ||
</syntaxhighlight> | </syntaxhighlight> | ||
[[Category:Core Function]] | [[Category:Core Function]] |
Latest revision as of 12:37, 14 June 2015
Modf( <x>, <intpart> )
Contents |
Description
Breaks x into an integral and a fractional part.
The integer part is stored in the variable pointed by intpart, and the fractional part is returned by the function.
Both parts have the same sign as x.
Parameters
x
Floating point value to break into parts.
intpart
Pointer to a variable (of the same type as x) where the integral part is stored with the same sign as x.
Return Value
The fractional part of x.
Remarks
None.
Example
my $intpart = 0.0; my $param = 3.14159265; my $fractpart = modf ($param, $intpart); printf ("%f = %f + %f \n", $param, $intpart, $fractpart); // Prints: 3.141593 = 3.000000 + 0.141593