C: nula

Jindroush jindroush na seznam.cz
Neděle Březen 21 19:22:21 CET 2021


Rule 10.1 addresses a different issue. It demands, among other things, 
that an expression which is assigned to an unsigned variable should 
itself be unsigned. This means that any constant or constant expression 
should itself be of "unsigned" type - including the constant '0'. The 
rationale behind this is that it is helpful to maintain consistent 
signedness when constructing arithmetic expressions, even if the 
omission of a 'U' suffix makes no difference to the result.

On 21.03.2021 19:16, Miroslav Draxal wrote:
>
> Dobrý den,
>
> Tak jsem na své projekty pustil MISRU2012. Nestačím se divit. Zatím, 
> co mě nejvíc udivuje, že 0 může být signed i unsigned. Do teď jsem si 
> myslel, že 0 je nic, nemá žádné znaménko. Nebo je to jinak? U čísel 
> !=0 je mi to jasné.
>
> Čili
>
> unsigned u = (unsigned)0;
>
> nebo
>
> unsigned u = 0u;
>
> Míra
>
>
> _______________________________________________
> HW-list mailing list  -  sponsored by www.HW.cz
> Hw-list at list.hw.cz
> http://list.hw.cz/mailman/listinfo/hw-list


-- 
Jindroush <jindroush at seznam.cz>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://list.hw.cz/pipermail/hw-list/attachments/20210321/79520c85/attachment.html>


Další informace o konferenci Hw-list