signed Signed integer specifier

signed Signed integer specifier

signed int equals int, but signed char differs from char. Query SCHAR_MIN and INT_MIN for limits; signed overflow is undefined, not wrapping.

CategoryType specifiers
KindKeyword / Statement
C standardC89 / C90

📝 Syntax

signed char sc = -128;

▶ Example

Edit the C code below and click Run; the server compiles and executes it:

Output:

SCHAR_MIN = -128
offset = -5
ℹ️ Info SCHAR_MIN = -128 reflects a common GCC 10.2 target with 8-bit bytes and two's-complement representation. The standard guarantees only that SCHAR_MIN is no greater than -127, so the example uses the macro rather than a hard-coded minimum.

📚 Related Tutorials

❓ FAQ

QAre char and signed char the same type?
ANo. Even when an implementation gives plain char a signed representation, char and signed char remain distinct types. signed char unambiguously guarantees that negative values can be represented.
QShould code use signed int or int?
AThey are exactly equivalent, so the shorter int is customary. signed is more useful for signed char or when explicitly emphasizing signedness for teaching purposes.
QCan -128 always be used as the minimum signed char value?
ANo. The standard requires only that signed char's minimum be no greater than -127. Portable code should use SCHAR_MIN from limits.h and handle boundaries according to the target implementation.
Web-Tutorial.com

Web-Tutorial Tech Team

A team of developers maintaining programming tutorials. Each tutorial is written and reviewed by developers with expertise in that field. We work to keep our content accurate and reliable — if you spot an issue, please let us know.

Content reviewed by MOTO · Found an error? Report it

100%

🙏 帮我们做得更好

我们是刚上线的编程教程站,几个人的小团队,精力有限。页面虽经检查,难免还有疏漏——链接失效、排版错乱、内容有误、语言生硬……

如果您发现了,麻烦告诉我们,我们会在收到反馈后第一时间进行修复,再次感谢您的光临 🙏