[Cfp-interest 2408] Re: x++ and DFP

Vincent Lefevre vincent at vinc17.net
Thu Mar 24 04:13:02 PDT 2022


On 2022-03-24 10:41:14 -0000, Mike Cowlishaw wrote:
> > C23 says in 6.5.2.4 Postfix increment and decrement operators 
> > that "1" is added.  Joseph Myers has raised the question:
> > Which quantum exponent does that "1" have?
> > 
> > For example, should it be 1e0 or 1000000e-6 for 7 digit DFP numbers?
> > 
> > My guess is:  the nearest quantum exponent of what 'x' has.
> 
> I think that could have some odd effects when 'x' has extreme exponents.
> 
> I would/do use 1e0 (that is, '1', as written, not '1.0', '1.00', etc.) and
> calculate using the rules for addition or subtraction.

The term used by the C23 draft (and C17) is "incremented". The value 1
for the increment makes sense for the integer and pointer types, but
not really for floating-point types, unless the idea is to apply it on
a subset of values that correspond to the integers (that is, integers
are represented in a floating-point type instead of an integer type).
So, from this point of view, I think that the quantum exponent of the
increment should be 0.

-- 
Vincent Lefèvre <vincent at vinc17.net> - Web: <https://www.vinc17.net/>
100% accessible validated (X)HTML - Blog: <https://www.vinc17.net/blog/>
Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)


More information about the Cfp-interest mailing list