Numbers
Let’s learn about Dart's number types.
The num
Type
If we want a variable that has a number value, we will declare it using the num
data type.
The basic syntax is as follows:
Press + to interact
// Method 1num variableName = Number Literal// Method 2num variableName = Number Variable
Let’s look at an example.
Press + to interact
main() {num firstNumber = 5;num secondNumber = 5.1;num thirdNumber = firstNumber;// Driver Codeprint(firstNumber);print(secondNumber);print(thirdNumber);}
Dart numbers are further divided into two subtypes:
Create a free account to access the full course.
By signing up, you agree to Educative's Terms of Service and Privacy Policy