Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Properties of Numbers | Variables and Data Types
Introduction to Dart

Properties of NumbersProperties of Numbers

We already know about int and double. This сhapter will teach how to work with these data types.

What are Properties?

In programming, just like in our life, things have their properties. It applies to all things. The properties of cars include brand, maximum speed, engine capacity, etc. The book properties include the author, genre, and number of pages.

Image

To find out what is stored in the property, you need:

Properties of int

  • isEven :

This property stores a bool value about whether the number is even or not. If the number is even, true is stored in the property. If it is negative, then false.

dart

main.dart

We don't need to program to know that 2 is even. But if the result in the variable stores the result of a mathematical expression, the properties will be beneficial to learn more.

dart

main.dart

The computer calculated the expression (result = -2852). The number is even.

  • isNegative :

We will get true if the number is negative. If the number is positive or 0, we will get false.

dart

main.dart

All the properties listed above are properties of the int type. These properties are not present in other data types (even in double, although they are also numbers).

Every data type has its own properties, and you will get acquainted with them eventually. But at this stage, it's crucial to understand that all data types are different, and each one requires its own approach.

question-icon

Use the isEven property and check if an even number is stored in the num variable.

print();

Натисніть або перетягніть елементи та заповніть пропуски

Все було зрозуміло?

Секція 2. Розділ 3
course content

Зміст курсу

Introduction to Dart

Properties of NumbersProperties of Numbers

We already know about int and double. This сhapter will teach how to work with these data types.

What are Properties?

In programming, just like in our life, things have their properties. It applies to all things. The properties of cars include brand, maximum speed, engine capacity, etc. The book properties include the author, genre, and number of pages.

Image

To find out what is stored in the property, you need:

Properties of int

  • isEven :

This property stores a bool value about whether the number is even or not. If the number is even, true is stored in the property. If it is negative, then false.

dart

main.dart

We don't need to program to know that 2 is even. But if the result in the variable stores the result of a mathematical expression, the properties will be beneficial to learn more.

dart

main.dart

The computer calculated the expression (result = -2852). The number is even.

  • isNegative :

We will get true if the number is negative. If the number is positive or 0, we will get false.

dart

main.dart

All the properties listed above are properties of the int type. These properties are not present in other data types (even in double, although they are also numbers).

Every data type has its own properties, and you will get acquainted with them eventually. But at this stage, it's crucial to understand that all data types are different, and each one requires its own approach.

question-icon

Use the isEven property and check if an even number is stored in the num variable.

print();

Натисніть або перетягніть елементи та заповніть пропуски

Все було зрозуміло?

Секція 2. Розділ 3
some-alt