[metadata]
id = "INT16-C"
type = "recommendation"
category = "INT"
number = 16
title = "Do not make assumptions about representation of signed integers"
description = """
Although many common implementations use a two's complement representation of
signed integers, the C Standard declares such use asimplementation-definedand
allows all of the following representations: This is a specific example
ofMSC14-C. Do not introduce unnecessary platform dependencies. One way to check
whether a number is even or odd is to examine the least significant bit, but the
results will be inconsistent. Specifically, this example gives unexpected
behavior on all one's complement implementations:
"""
severity = "Medium"
likelihood = "Unlikely"
priority = "P2"
level = "L3"
cert_version = "2016 Edition (Wiki)"
last_modified = "May 20, 2025"
[rules.cert_c.INT16-C]
enabled = true
[references]
wiki = "https://wiki.sei.cmu.edu/confluence/display/c/INT16-C.+Do+not+make+assumptions+about+representation+of+signed+integers"