Liste des Groupes | Revenir à c arch |
On Thu, 5 Sep 2024 14:05:08 +0000, Scott Lurndal wrote:That would be a /saturating/ ranged type. Neither Pascal nor Ada provides such types.
Terje Mathisen <terje.mathisen@tmsw.no> writes:result = min(max(min_range,x),max_range);David Brown wrote:>
>It would be nice if C had subrange types like Pascal or Ada, but it doe=s not.=C2=A0 Usually int - or sizeed ints - are the practical choice.
>
>
Agreed 100%
Although absent architecture support, how does one ensure that the
value remains within the subrange?
or for 2^n valuesThat would be a /wrap-around/ ranged type (if I understand the code correctly). Pascal does not provide such; Ada does (modular integers) and for any modulus, not only powers of two.
result = ( ( x << (64-width) ) >> (64-width) );
The top is 2 instructions, the bottom 1 (both signed and unsigned).
Les messages affichés proviennent d'usenet.