Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is -5 an integer literal?

Tags:

c++

literals

Is -5 an integer literal? Or is 5 a literal, and -5 is an expression with unary minus taking a literal as an argument? The question arose when I was wondering how to hardcode smallest signed integer values.

like image 290
Armen Tsirunyan Avatar asked Oct 12 '10 21:10

Armen Tsirunyan


People also ask

Is integer A literal in Python?

Integers. When you create an integer like this, the value 25 is called an integer literal because the integer is literally typed into the code. int("25") is not an integer literal because the integer value is created from a string.

What are the 6 types of literals?

Primitive data types include int, byte, short, float, boolean, double, and char, whereas non-primitive data types include arrays, string, and classes. The primitive literals in java int, byte, short, float, boolean, double, and char represent certain signed integer values.

Are numbers literals?

Answer and Explanation: Literal numbers are the letters used in an algebraic expression to represent a number or an unknown quantity. Literal numbers, or simply called literals, are the variables in an equation. Literal numbers also follow the rules of arithmetic operations.

Which is an example of a numeric literal?

The terms literal and constant value are synonymous and refer to a fixed data value. For example, 'JACK', 'BLUE ISLAND', and '101' are all character literals; 5001 is a numeric literal.


1 Answers

It's a unary minus followed by 5 as an integer literal. Yes, that makes it somewhat difficult to represent the smallest possible integer in twos complement.

like image 120
Jerry Coffin Avatar answered Sep 21 '22 13:09

Jerry Coffin