Fdiv()

From TinyMUX
Revision as of 05:03, 17 January 2006 by Ian (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Description

FUNCTION: fdiv(number1, number2)

Returns the floating-point quotient from dividing number1 by number2. number may be a floating-point number, and a floating-point result is returned.

Related Topics: add(), fmod(), mod(), mul(), round(), sub(), trunc().

Examples

> say fdiv(15,3)
You say "5"
> say fdiv(16,3)
You say "5.333333"
> say fdiv(17,3)
You say "5.666667"
> say fdiv(18,3)
You say "6"
> say fdiv(-17,3)
You say "-5.666667"
> say fdiv(10,3.5)
You say "2.857143"

Server Differences

The basic behavior of fdiv() is the same across PennMUSH, TinyMUSH, and TinyMUX, however, the usual floating-point differences apply. For example:

On PennMUSH, fdiv(1,1e-9) ==> '1000000000' while fdiv(1,1e-10) ==> '#-1 DIVISION BY ZERO'.
On TinyMUSH, fdiv(1,1e-10) ==> '10000000000' while fdiv(1,1e-130) ==> '9999999999999999366518088823188676468029287122850159299994507296276799832366962053631754981778769796749861527090709766158759755776'
On TinyMUX, fdiv(0,0) ==> 'Ind', fdiv(1,0) ==> '+Inf', fdiv(-1,0) ==> '-Inf', and fdiv(1,1e-130) ==> '9.999999999999999E129'.
RhostMUSH's fdiv() behavior equals that of TinyMUSH.