Number protocol

From Erights

(Difference between revisions)
Jump to: navigation, search
(Protocol: typo)
(note on template)
Line 4: Line 4:
{{XXX}} This list is not complete, not properly documented, and not discussed.
{{XXX}} This list is not complete, not properly documented, and not discussed.
 +
 +
{{XXX}} Consider whether this page could be turned into a template which generates tests of the number protocol for specific number types.
==Protocol==
==Protocol==

Revision as of 23:30, 7 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.

XXX Consider whether this page could be turned into a template which generates tests of the number protocol for specific number types.

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.

min/1

Signature: min(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.
Personal tools
more tools