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 integersint num1 = 6;// positive numberint num2 = -6;// negative number// printing both numbersprint(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 integersint num = 6.56;// fractional value// printing both numbersprint(num);}