In the Dart programming language, an integer is represented by the int
keyword. As we may know, integers include whole numbers (i.e., non-decimal positive and negative numbers). For every integer, four bytes are allocated in the memory.
import 'dart:convert'; void main() { // Two integers int num1 = 6;// positive number int num2 = -6;// negative number // printing both numbers print(num1); print(num2); }
The code below throws an error because it is not possible to assign a fractional value to an integer.
For fractional values, we use
double
datatype.
import 'dart:convert'; void main() { // Two integers int num = 6.56;// fractional value // printing both numbers print(num); }
RELATED TAGS
View all Courses