http://wiki.erights.org/mediawiki/index.php?title=Number_protocol&feed=atom&action=historyNumber protocol - Revision history2024-03-19T12:21:57ZRevision history for this page on the wikiMediaWiki 1.15.5-7http://wiki.erights.org/mediawiki/index.php?title=Number_protocol&diff=1753&oldid=prevKevin Reid: add modPow, missing space for max and min, fix XXXes, mention other-number-type issue2009-07-31T04:51:24Z<p>add modPow, missing space for max and min, fix XXXes, mention other-number-type issue</p>
<p><b>New page</b></p><div>For some type T which is like a number, these are the conventional messages to implement.<br />
<br />
This protocol is implemented by [[Integer]] and [[Float64]].<br />
<br />
{{XXX|This list is not complete, not properly documented, and not discussed.}}<br />
<br />
{{XXX|Consider whether this page could be turned into a template which generates tests of the number protocol for specific number types.}}<br />
<br />
{{XXX|This documentation needs to acknowledge behavior with respect to numbers of other types; e.g. where this is an integer and an argument is a float. Just saying type T doesn't acknowlege that the result might be of another type.}}<br />
<br />
==Protocol==<br />
<br />
{{instance msgdoc|add|1|<var>other</var> :T|T}}<br />
<br />
Sugar expansion of [[+]]. {{XXX}} write documentation<br />
<br />
{{instance msgdoc|subtract|1|<var>other</var> :T|T}}<br />
<br />
Sugar expansion of [[-]]. {{XXX}} write documentation<br />
<br />
{{instance msgdoc|multiply|1|<var>other</var> :T|T}}<br />
<br />
Sugar expansion of [[*]]. {{XXX}} write documentation<br />
<br />
{{instance msgdoc|floorDivide|1|<var>other</var> :T|T}}<br />
<br />
Sugar expansion of [[operator //|//]]. {{XXX}} write documentation<br />
<br />
{{instance msgdoc|approxDivide|1|<var>other</var> :T|T}}<br />
<br />
Sugar expansion of [[operator /|/]]. {{XXX}} write documentation<br />
<br />
{{instance msgdoc|remainder|1|<var>other</var> :T|T}}<br />
<br />
Sugar expansion of [[operator %|%]]. {{XXX}} write documentation<br />
<br />
{{instance msgdoc|mod|1|<var>other</var> :T|T}}<br />
<br />
Sugar expansion of [[operator %%|%%]]. {{XXX}} write documentation<br />
<br />
{{instance msgdoc|pow|1|<var>other</var> :T|T}}<br />
<br />
Sugar expansion of [[operator **|**]]. {{XXX}} write documentation<br />
<br />
{{instance msgdoc|modPow|2|<var>exponent</var> :T, <var>modulus</var> :T|T}}<br />
<br />
Sugar expansion of <code>this ** exponent %% modulus</code>.<br />
<br />
{{specbycode|<var>this</var>.pow(<var>exponent</var>).mod(<var>modulus</var>)}}<br />
<br />
It is expected that when this is an integer, <var>modulus</var> is a nonzero integer and <var>exponent</var> is a positive integer, this operation will be [http://en.wikipedia.org/wiki/Modular_exponentiation implemented efficiently].<br />
<br />
{{XXX|In [[E-on-Java]], a negative modulus will throw an exception rather than computing the compositional answer. The above spec I just wrote contradicts this. Resolve. --[[User:Kevin Reid|Kevin Reid]] 23:51, 30 July 2009 (CDT)}} [[Category:Unresolved design issues]]<br />
<br />
{{instance msgdoc|negate|0||T}}<br />
<br />
Sugar expansion of [[-]]. Return the additive inverse of the receiver.<br />
<br />
{{instance msgdoc|abs|0||T}}<br />
<br />
Return the [http://en.wikipedia.org/wiki/Absolute_value absolute value] of the receiver.<br />
<br />
{{instance msgdoc|max|1|<var>other</var> :T|T}}<br />
<br />
Compare the recipient to <var>other</var>, and return whichever is greater.<br />
<br />
{{instance msgdoc|min|1|<var>other</var> :T|T}}<br />
<br />
Compare the recipient to <var>other</var>, and return whichever is lesser.<br />
<br />
{{stub}}</div>Kevin Reidhttp://wiki.erights.org/mediawiki/index.php?title=Number_protocol&diff=3837&oldid=prevKevin Reid: note on template2009-03-07T23:30:25Z<p>note on template</p>
<table style="background-color: white; color:black;">
<col class='diff-marker' />
<col class='diff-content' />
<col class='diff-marker' />
<col class='diff-content' />
<tr valign='top'>
<td colspan='2' style="background-color: white; color:black;">←Older revision</td>
<td colspan='2' style="background-color: white; color:black;">Revision as of 23:30, 7 March 2009</td>
</tr>
<tr><td colspan="2" class="diff-lineno">Line 4:</td>
<td colspan="2" class="diff-lineno">Line 4:</td></tr>
<tr><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"></td><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"></td></tr>
<tr><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div>{{XXX}} This list is not complete, not properly documented, and not discussed.</div></td><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div>{{XXX}} This list is not complete, not properly documented, and not discussed.</div></td></tr>
<tr><td colspan="2"> </td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div><ins style="color: red; font-weight: bold; text-decoration: none;"></ins></div></td></tr>
<tr><td colspan="2"> </td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div><ins style="color: red; font-weight: bold; text-decoration: none;">{{XXX}} Consider whether this page could be turned into a template which generates tests of the number protocol for specific number types.</ins></div></td></tr>
<tr><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"></td><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"></td></tr>
<tr><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div>==Protocol==</div></td><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div>==Protocol==</div></td></tr>
<!-- diff generator: internal 2024-03-19 12:21:58 -->
</table>Kevin Reidhttp://wiki.erights.org/mediawiki/index.php?title=Number_protocol&diff=3836&oldid=prevKevin Reid: /* Protocol */ typo2009-03-04T00:15:27Z<p><span class="autocomment">Protocol: </span> typo</p>
<table style="background-color: white; color:black;">
<col class='diff-marker' />
<col class='diff-content' />
<col class='diff-marker' />
<col class='diff-content' />
<tr valign='top'>
<td colspan='2' style="background-color: white; color:black;">←Older revision</td>
<td colspan='2' style="background-color: white; color:black;">Revision as of 00:15, 4 March 2009</td>
</tr>
<tr><td colspan="2" class="diff-lineno">Line 38:</td>
<td colspan="2" class="diff-lineno">Line 38:</td></tr>
<tr><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div>Compare the recipient to <var>other</var>, and return whichever is greater.</div></td><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div>Compare the recipient to <var>other</var>, and return whichever is greater.</div></td></tr>
<tr><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"></td><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"></td></tr>
<tr><td class='diff-marker'>-</td><td style="background: #ffa; color:black; font-size: smaller;"><div>{{instance msgdoc|<del class="diffchange diffchange-inline">max</del>|1|<var>other</var> :T|T}}</div></td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div>{{instance msgdoc|<ins class="diffchange diffchange-inline">min</ins>|1|<var>other</var> :T|T}}</div></td></tr>
<tr><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div>Compare the recipient to <var>other</var>, and return whichever is lesser.</div></td><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div>Compare the recipient to <var>other</var>, and return whichever is lesser.</div></td></tr>
<tr><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"></td><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"></td></tr>
<tr><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div>{{stub}}</div></td><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div>{{stub}}</div></td></tr>
<!-- diff generator: internal 2024-03-19 12:21:58 -->
</table>Kevin Reidhttp://wiki.erights.org/mediawiki/index.php?title=Number_protocol&diff=3835&oldid=prevKevin Reid at 00:14, 4 March 20092009-03-04T00:14:51Z<p></p>
<table style="background-color: white; color:black;">
<col class='diff-marker' />
<col class='diff-content' />
<col class='diff-marker' />
<col class='diff-content' />
<tr valign='top'>
<td colspan='2' style="background-color: white; color:black;">←Older revision</td>
<td colspan='2' style="background-color: white; color:black;">Revision as of 00:14, 4 March 2009</td>
</tr>
<tr><td colspan="2" class="diff-lineno">Line 3:</td>
<td colspan="2" class="diff-lineno">Line 3:</td></tr>
<tr><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div>This protocol is implemented by [[Integer]] and [[Float64]].</div></td><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div>This protocol is implemented by [[Integer]] and [[Float64]].</div></td></tr>
<tr><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"></td><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"></td></tr>
<tr><td class='diff-marker'>-</td><td style="background: #ffa; color:black; font-size: smaller;"><div>{{XXX<del class="diffchange diffchange-inline">|</del>This list is not complete, not properly documented, and not discussed.<del class="diffchange diffchange-inline">}}</del></div></td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div>{{XXX<ins class="diffchange diffchange-inline">}} </ins>This list is not complete, not properly documented, and not discussed.</div></td></tr>
<tr><td class='diff-marker'>-</td><td style="background: #ffa; color:black; font-size: smaller;"><div> </div></td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div></div></td></tr>
<tr><td class='diff-marker'>-</td><td style="background: #ffa; color:black; font-size: smaller;"><div><del class="diffchange diffchange-inline">{{XXX|Consider whether this page could be turned into a template which generates tests of the number protocol for specific number types.}}</del></div></td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div></div></td></tr>
<tr><td class='diff-marker'>-</td><td style="background: #ffa; color:black; font-size: smaller;"><div> </div></td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div></div></td></tr>
<tr><td class='diff-marker'>-</td><td style="background: #ffa; color:black; font-size: smaller;"><div><del class="diffchange diffchange-inline">{{XXX|This documentation needs to acknowledge behavior with respect to numbers of other types; e.g. where this is an integer and an argument is a float. Just saying type T doesn't acknowlege that the result might be of another type.}}</del></div></td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div></div></td></tr>
<tr><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"></td><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"></td></tr>
<tr><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div>==Protocol==</div></td><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div>==Protocol==</div></td></tr>
<tr><td colspan="2" class="diff-lineno">Line 30:</td>
<td colspan="2" class="diff-lineno">Line 26:</td></tr>
<tr><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"></td><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"></td></tr>
<tr><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div>Sugar expansion of [[operator /|/]]. {{XXX}} write documentation</div></td><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div>Sugar expansion of [[operator /|/]]. {{XXX}} write documentation</div></td></tr>
<tr><td class='diff-marker'>-</td><td style="background: #ffa; color:black; font-size: smaller;"><div><del style="color: red; font-weight: bold; text-decoration: none;"></del></div></td><td colspan="2"> </td></tr>
<tr><td class='diff-marker'>-</td><td style="background: #ffa; color:black; font-size: smaller;"><div><del style="color: red; font-weight: bold; text-decoration: none;">{{instance msgdoc|remainder|1|<var>other</var> :T|T}}</del></div></td><td colspan="2"> </td></tr>
<tr><td class='diff-marker'>-</td><td style="background: #ffa; color:black; font-size: smaller;"><div><del style="color: red; font-weight: bold; text-decoration: none;"></del></div></td><td colspan="2"> </td></tr>
<tr><td class='diff-marker'>-</td><td style="background: #ffa; color:black; font-size: smaller;"><div><del style="color: red; font-weight: bold; text-decoration: none;">Sugar expansion of [[operator %|%]]. {{XXX}} write documentation</del></div></td><td colspan="2"> </td></tr>
<tr><td class='diff-marker'>-</td><td style="background: #ffa; color:black; font-size: smaller;"><div><del style="color: red; font-weight: bold; text-decoration: none;"></del></div></td><td colspan="2"> </td></tr>
<tr><td class='diff-marker'>-</td><td style="background: #ffa; color:black; font-size: smaller;"><div><del style="color: red; font-weight: bold; text-decoration: none;">{{instance msgdoc|mod|1|<var>other</var> :T|T}}</del></div></td><td colspan="2"> </td></tr>
<tr><td class='diff-marker'>-</td><td style="background: #ffa; color:black; font-size: smaller;"><div><del style="color: red; font-weight: bold; text-decoration: none;"></del></div></td><td colspan="2"> </td></tr>
<tr><td class='diff-marker'>-</td><td style="background: #ffa; color:black; font-size: smaller;"><div><del style="color: red; font-weight: bold; text-decoration: none;">Sugar expansion of [[operator %%|%%]]. {{XXX}} write documentation</del></div></td><td colspan="2"> </td></tr>
<tr><td class='diff-marker'>-</td><td style="background: #ffa; color:black; font-size: smaller;"><div><del style="color: red; font-weight: bold; text-decoration: none;"></del></div></td><td colspan="2"> </td></tr>
<tr><td class='diff-marker'>-</td><td style="background: #ffa; color:black; font-size: smaller;"><div><del style="color: red; font-weight: bold; text-decoration: none;">{{instance msgdoc|pow|1|<var>other</var> :T|T}}</del></div></td><td colspan="2"> </td></tr>
<tr><td class='diff-marker'>-</td><td style="background: #ffa; color:black; font-size: smaller;"><div><del style="color: red; font-weight: bold; text-decoration: none;"></del></div></td><td colspan="2"> </td></tr>
<tr><td class='diff-marker'>-</td><td style="background: #ffa; color:black; font-size: smaller;"><div><del style="color: red; font-weight: bold; text-decoration: none;">Sugar expansion of [[operator **|**]]. {{XXX}} write documentation</del></div></td><td colspan="2"> </td></tr>
<tr><td class='diff-marker'>-</td><td style="background: #ffa; color:black; font-size: smaller;"><div><del style="color: red; font-weight: bold; text-decoration: none;"></del></div></td><td colspan="2"> </td></tr>
<tr><td class='diff-marker'>-</td><td style="background: #ffa; color:black; font-size: smaller;"><div><del style="color: red; font-weight: bold; text-decoration: none;">{{instance msgdoc|modPow|2|<var>exponent</var> :T, <var>modulus</var> :T|T}}</del></div></td><td colspan="2"> </td></tr>
<tr><td class='diff-marker'>-</td><td style="background: #ffa; color:black; font-size: smaller;"><div><del style="color: red; font-weight: bold; text-decoration: none;"></del></div></td><td colspan="2"> </td></tr>
<tr><td class='diff-marker'>-</td><td style="background: #ffa; color:black; font-size: smaller;"><div><del style="color: red; font-weight: bold; text-decoration: none;">Sugar expansion of <code>this ** exponent %% modulus</code>.</del></div></td><td colspan="2"> </td></tr>
<tr><td class='diff-marker'>-</td><td style="background: #ffa; color:black; font-size: smaller;"><div><del style="color: red; font-weight: bold; text-decoration: none;"></del></div></td><td colspan="2"> </td></tr>
<tr><td class='diff-marker'>-</td><td style="background: #ffa; color:black; font-size: smaller;"><div><del style="color: red; font-weight: bold; text-decoration: none;">{{specbycode|<var>this</var>.pow(<var>exponent</var>).mod(<var>modulus</var>)}}</del></div></td><td colspan="2"> </td></tr>
<tr><td class='diff-marker'>-</td><td style="background: #ffa; color:black; font-size: smaller;"><div><del style="color: red; font-weight: bold; text-decoration: none;"></del></div></td><td colspan="2"> </td></tr>
<tr><td class='diff-marker'>-</td><td style="background: #ffa; color:black; font-size: smaller;"><div><del style="color: red; font-weight: bold; text-decoration: none;">It is expected that when this is an integer, <var>modulus</var> is a nonzero integer and <var>exponent</var> is a positive integer, this operation will be [http://en.wikipedia.org/wiki/Modular_exponentiation implemented efficiently].</del></div></td><td colspan="2"> </td></tr>
<tr><td class='diff-marker'>-</td><td style="background: #ffa; color:black; font-size: smaller;"><div><del style="color: red; font-weight: bold; text-decoration: none;"></del></div></td><td colspan="2"> </td></tr>
<tr><td class='diff-marker'>-</td><td style="background: #ffa; color:black; font-size: smaller;"><div><del style="color: red; font-weight: bold; text-decoration: none;">{{XXX|In [[E-on-Java]], a negative modulus will throw an exception rather than computing the compositional answer. The above spec I just wrote contradicts this. Resolve. --[[User:Kevin Reid|Kevin Reid]] 23:51, 30 July 2009 (CDT)}} [[Category:Unresolved design issues]]</del></div></td><td colspan="2"> </td></tr>
<tr><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"></td><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"></td></tr>
<tr><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div>{{instance msgdoc|negate|0||T}}</div></td><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div>{{instance msgdoc|negate|0||T}}</div></td></tr>
<tr><td colspan="2" class="diff-lineno">Line 62:</td>
<td colspan="2" class="diff-lineno">Line 36:</td></tr>
<tr><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"></td><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"></td></tr>
<tr><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div>{{instance msgdoc|max|1|<var>other</var> :T|T}}</div></td><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div>{{instance msgdoc|max|1|<var>other</var> :T|T}}</div></td></tr>
<tr><td class='diff-marker'>-</td><td style="background: #ffa; color:black; font-size: smaller;"><div><del style="color: red; font-weight: bold; text-decoration: none;"></del></div></td><td colspan="2"> </td></tr>
<tr><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div>Compare the recipient to <var>other</var>, and return whichever is greater.</div></td><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div>Compare the recipient to <var>other</var>, and return whichever is greater.</div></td></tr>
<tr><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"></td><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"></td></tr>
<tr><td class='diff-marker'>-</td><td style="background: #ffa; color:black; font-size: smaller;"><div>{{instance msgdoc|<del class="diffchange diffchange-inline">min</del>|1|<var>other</var> :T|T}}</div></td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div>{{instance msgdoc|<ins class="diffchange diffchange-inline">max</ins>|1|<var>other</var> :T|T}}</div></td></tr>
<tr><td class='diff-marker'>-</td><td style="background: #ffa; color:black; font-size: smaller;"><div> </div></td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div></div></td></tr>
<tr><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div>Compare the recipient to <var>other</var>, and return whichever is lesser.</div></td><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div>Compare the recipient to <var>other</var>, and return whichever is lesser.</div></td></tr>
<tr><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"></td><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"></td></tr>
<tr><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div>{{stub}}</div></td><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div>{{stub}}</div></td></tr>
<!-- diff generator: internal 2024-03-19 12:21:58 -->
</table>Kevin Reid