nmh-workers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [nmh-workers] Ordinal Indicators.


From: Ralph Corderoy
Subject: Re: [nmh-workers] Ordinal Indicators.
Date: Mon, 08 Jul 2019 17:25:42 +0100

Hi,

Is -42nd handled?  IIRC we demand C99 so we know rounding is towards
zero.  But C's remainder operator, ‘%’, returns the sign of the
dividend, unlike modulo.  And then there's two's complement so INT_MIN
can't be made positive.

    $ for a in ' -' ' '; do
    >     for b in ' -' ' '; do
    >         fmttest -raw \
    >             -format "%(num${a}42) /${b}10 = %(divide${b}10)\t%(num${a}42) 
%%${b}10 = %(modulo${b}10)" ''
    >     done
    > done
    -42 / -10 = 4   -42 % -10 = -2
    -42 / 10 = -4   -42 % 10 = -2
    42 / -10 = -4   42 % -10 = 2
    42 / 10 = 4     42 % 10 = 2
    $ 

-- 
Cheers, Ralph.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]