[LLVMdev] [RFC] Add a scaled number class (was: Add a simple soft-float class)

James Courtier-Dutton james.dutton at gmail.com
Sun Jun 22 00:48:18 PDT 2014


On 21 June 2014 00:40, Sean Silva <chisophugis at gmail.com> wrote:
>
>
> my 2c: describe it as "an approximate, high-dynamic-range unsigned integer".
>
> That doesn't lend itself to something easy to type, but "ApproxHDRUint"
> might be doable. Plus, it sounds sort of scary.
>
> Having something in the name that suggests that it is an integer should ward
> off any attempt to use it for numerics.
>
> -- Sean Silva
>

I would suggest that "high-dynamic-range" is also the wrong word. It
is not actually providing any extra dynamic range.
Having something that can go from 0 to 20 in steps of 2 has no better
dynamic range as something that can go from 0 to 10 in steps of 1.
Simply calling it "scaled unsigned integer" is more accurate.
Or "unsigned integer with scale factor".

I think it would also be a good idea to explain what maths operations
you are likely to want to do.
For example, if the number is 20, with scale factor 2, and you add 1
with scale factor 1 to it, the answer is undefined.
If all you are going to do is somehow reach a value and then is won't
change, and the only operations you are going to do are "compare"
operations, then that is something that is easier to understand for
other programmers.

Just out of curiosity, what is the requirement or use case that is
driving a "scaled unsigned integer" instead of say just using an
integer with more bits.

James



More information about the llvm-dev mailing list