Integer
From Erights
Kevin Reid (Talk | contribs) |
Kevin Reid (Talk | contribs) (dump in some tests) |
||
Line 12: | Line 12: | ||
<var>string</var> must contain only an optional leading minus sign "-" (U+002D), followed by at least one digit of the specified base ("0"-"9" for bases up to 10, then "a"-"z" or "A"-"Z" for additional digits up to base 36). | <var>string</var> must contain only an optional leading minus sign "-" (U+002D), followed by at least one digit of the specified base ("0"-"9" for bases up to 10, then "a"-"z" or "A"-"Z" for additional digits up to base 36). | ||
+ | |||
+ | ==Tests== | ||
+ | |||
+ | Many E implementations have multiple representations of Integers for different size ranges. These implementations ''must'' be indistinguishable, or there must be exactly one representation for any given integer. | ||
+ | |||
+ | ? def a := 4 | ||
+ | # value: 4 | ||
+ | |||
+ | ? def b := (400000000000000000000 // 100000000000000000000) | ||
+ | # value: 4 | ||
+ | |||
+ | ? a == b | ||
+ | # value: true | ||
+ | |||
+ | ? a.__getAllegedType() | ||
+ | # value: int | ||
+ | |||
+ | ? b.__getAllegedType() | ||
+ | # value: int | ||
+ | |||
+ | ? 400000000000000000000.__getAllegedType() | ||
+ | # value: int | ||
[[Category:ELib specification]] | [[Category:ELib specification]] | ||
{{stub}} | {{stub}} |
Revision as of 22:45, 14 May 2009
Integer is one of the built-in numeric types in ELib.
Contents |
Maker protocol
run/1
run(string :String) :Integer
Equivalent to thisInteger.run(string, 10)
.
run/2
run(string :String, base :(0..36)) :Integer
Convert string to an integer. If it does not match the following syntax then an exception is thrown. XXX If sealed throw is accepted, then there must be a way to supply an ejector to handle failure here.
string must contain only an optional leading minus sign "-" (U+002D), followed by at least one digit of the specified base ("0"-"9" for bases up to 10, then "a"-"z" or "A"-"Z" for additional digits up to base 36).
Tests
Many E implementations have multiple representations of Integers for different size ranges. These implementations must be indistinguishable, or there must be exactly one representation for any given integer.
? def a := 4 # value: 4 ? def b := (400000000000000000000 // 100000000000000000000) # value: 4 ? a == b # value: true ? a.__getAllegedType() # value: int ? b.__getAllegedType() # value: int ? 400000000000000000000.__getAllegedType() # value: int
- 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.