Skip to content

Commit 1a67e98

Browse files
committed
nail down return types of colon radix notation
1 parent f30cc88 commit 1a67e98

File tree

1 file changed

+18
-2
lines changed

1 file changed

+18
-2
lines changed

S02-bits.pod

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ Synopsis 2: Bits and Pieces
1313

1414
Created: 10 Aug 2004
1515

16-
Last Modified: 18 Jun 2011
17-
Version: 234
16+
Last Modified: 6 Jul 2011
17+
Version: 235
1818

1919
This document summarizes Apocalypse 2, which covers small-scale
2020
lexical items and typological issues. (These Synopses also contain
@@ -3256,6 +3256,22 @@ and maybe a trailing Units type for an implied scaling. Leading and
32563256
trailing whitespace is ignored. Note also that leading C<0> by itself
32573257
I<never> implies octal in Perl 6.
32583258

3259+
In all these cases, the type produced will be the narrowest of Int,
3260+
Rat, or Num that can accurately represent the number. If no type can
3261+
represent it exactly, it should be returned as either a Rat or a Num,
3262+
whichever is more accurate. (Rat64 will tend to be more accurate
3263+
for numbers of normal or large magnitude, while Num64 may be more
3264+
accurate for numbers of very small magnitude, since the Rat's size
3265+
mismatch of numerator and denominator will eventually cost more
3266+
accuracy than the Num's exponent overhead. As a limiting case,
3267+
a Rat64 cannot represent any number smaller than :10<1*2**-64>.)
3268+
3269+
A consequence of the preceding is that you cannot make a FatRat using
3270+
colon notation. You must rely on constructors and constant folding:
3271+
3272+
(FatRat.new(1,1) * 2 ** -128)
3273+
FatRat.new(1, 2 ** 128) # same thing
3274+
32593275
Any of the adverbial forms may be used as a function:
32603276

32613277
:2($x) # "bin2num"

0 commit comments

Comments
 (0)