Number protocol
From Erights
(Difference between revisions)
(add modPow, missing space for max and min, fix XXXes, mention other-number-type issue) |
Kevin Reid (Talk | contribs) |
||
Line 3: | Line 3: | ||
This protocol is implemented by [[Integer]] and [[Float64]]. | This protocol is implemented by [[Integer]] and [[Float64]]. | ||
- | {{XXX | + | {{XXX}} This list is not complete, not properly documented, and not discussed. |
- | + | ||
- | + | ||
- | + | ||
- | + | ||
==Protocol== | ==Protocol== | ||
Line 30: | Line 26: | ||
Sugar expansion of [[operator /|/]]. {{XXX}} write documentation | Sugar expansion of [[operator /|/]]. {{XXX}} write documentation | ||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
{{instance msgdoc|negate|0||T}} | {{instance msgdoc|negate|0||T}} | ||
Line 62: | Line 36: | ||
{{instance msgdoc|max|1|<var>other</var> :T|T}} | {{instance msgdoc|max|1|<var>other</var> :T|T}} | ||
- | |||
Compare the recipient to <var>other</var>, and return whichever is greater. | Compare the recipient to <var>other</var>, and return whichever is greater. | ||
- | {{instance msgdoc| | + | {{instance msgdoc|max|1|<var>other</var> :T|T}} |
- | + | ||
Compare the recipient to <var>other</var>, and return whichever is lesser. | Compare the recipient to <var>other</var>, and return whichever is lesser. | ||
{{stub}} | {{stub}} |
Revision as of 00:14, 4 March 2009
For some type T which is like a number, these are the conventional messages to implement.
This protocol is implemented by Integer and Float64.
XXX This list is not complete, not properly documented, and not discussed.
Contents |
Protocol
add/1
- Signature: add(other :T) :T
Sugar expansion of +. XXX write documentation
subtract/1
- Signature: subtract(other :T) :T
Sugar expansion of -. XXX write documentation
multiply/1
- Signature: multiply(other :T) :T
Sugar expansion of *. XXX write documentation
floorDivide/1
- Signature: floorDivide(other :T) :T
Sugar expansion of //. XXX write documentation
approxDivide/1
- Signature: approxDivide(other :T) :T
Sugar expansion of /. XXX write documentation
negate/0
- Signature: negate() :T
Sugar expansion of -. Return the additive inverse of the receiver.
abs/0
- Signature: abs() :T
Return the absolute value of the receiver.
max/1
- Signature: max(other :T) :T
Compare the recipient to other, and return whichever is greater.
max/1
- Signature: max(other :T) :T
Compare the recipient to other, and return whichever is lesser.
- This page is a stub; it should be expanded with more information. If doing so, check the original E web site and the mailing list archives for content which could be moved into this page.