Boost logo

Boost :

Subject: Re: [boost] GSOC 2013
From: Michael Marcin (mike.marcin_at_[hidden])
Date: 2013-04-23 00:46:09


On 4/22/13 5:35 PM, Dmitriy Gorbel wrote:
>
> Michael Marcin-3 wrote
>> There is a typo: The range must be *grater* then the resolution
>>
>> I don't understand your types.
>>
>> cardinal<16> 0 <= n <= 65536
>>
>> This seems to be a 16 bit unsigned type but requires 17 bits to store
>> this range. It should probably be 0 <= n <= 65535.
>>
>> integral<4> -16 <= n <= 16
>>
>> Similar here this seem to be a 5 it signed integer but requires 6 bits
>> to store this range. It should probably be -16 <= n <= 15.
>>
>> nonnegative<8,-4> -256 < n < 256 in increments of 2^-4 = 1/16
>>
>> I don't understand how a type nonnegative can store values in (-256,0).
>>
>>
>> negatable<16,-8> -65536 < n < 65536 in increments of 2^-8
>> = 1/ 256
>>
>> This seems close to a fixed point type as I'm used to seeing it.
>> Although again the ranges seem wrong.
>>
>> I'm much more accustom to seeing fixed point number specified as
>> <Magnitude bits, Fractional Bits>
>> i.e. <16,8> instead of <16,-8>.
>> Still this representation makes sense because it specifies both
>> parameters in terms 2^x. It also supports something like <17,1> to give
>> a 16 bit type that has the range [-131072, 131071] in increments of 2.
>>
>> Still it might be surprising to those familiar with the more common
>> fixed-point notation.
>
> Here is no mistake in the example. I paste here part of the C++1y proposal
>

If these are correct could someone explain them to me.
Especially why a type named nonnegative can have a value of -255.


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk