Is the world coming to an end?
spir
denis.spir at gmail.com
Fri Apr 8 13:20:40 PDT 2011
On 04/08/2011 10:01 PM, Nick Sabalausky wrote:
> "Michel Fortin"<michel.fortin at michelf.com> wrote in message
> news:inn4bp$57s$1 at digitalmars.com...
>> On 2011-04-08 07:03:23 -0400, spir<denis.spir at gmail.com> said:
>>
>>> On 04/08/2011 07:25 AM, Nick Sabalausky wrote:
>>>> I want base PI literals :)
>>>>
>>>> Yum.
>>>
>>> I want base 1 literals
>>>
>>> Denis
>>
>> Like this?
>>
>> assert(0i == 0)
>> assert(0i0 == 1)
>> assert(0i00 == 2)
>> assert(0i000 == 3)
>> assert(0i0000000000_0000000000_0000000000_00 == 32)
>>
>
> Pardon my geekdom, but it would probably have to be:
>
> assert(0i == 0)
> assert(0i1 == 1)
> assert(0i11 == 2)
> assert(0i111 == 3)
> assert(0i1111111111_1111111111_1111111111_11 == 32)
>
>
> In general, number bases work like this:
>
> Assuming i=0 is the right-most digit:
> (digits.length (SIGMA) i=0) digit[i] * (base^^i)
>
> Or in less mathy notation:
>
> uint[] digits = [...blah...]; // digits[0] is the right-most digit
> auto finalValue = 0;
> foreach(i; 0..digits.length)
> finalValue += digits[i] * (base^^i);
>
> So using 0 as the only digit in base 1 would result in all numbers being
> equal to 0. But using 1 as the only digit would work.
True, for using the same algorithm to compute the numeric value. But you're
missing the point in base 1 there cannot be '1' digits, as per definition ;-)
If I correctly understand Michel's meaning, he just provided a notation mapping
natural numbers to sets (actually sequences): Number n maps to n
whatever-symbol. Could have been:
assert(0i$$$ == 3);
but since '0's are available in base 1...
Denis
--
_________________
vita es estrany
spir.wikidot.com
More information about the Digitalmars-d
mailing list