Dart int ceilToDouble()
Syntax & Examples


int.ceilToDouble() method

The `ceilToDouble` method in Dart returns the double representation of this integer.


Syntax of int.ceilToDouble()

The syntax of int.ceilToDouble() method is:

 double ceilToDouble() 

This ceilToDouble() method of int returns this.toDouble().

Return Type

int.ceilToDouble() returns value of type double.



✐ Examples

1 Convert an integer to double

In this example,

  1. We assign the value 5 to the integer variable num1.
  2. We convert num1 to a double using the ceilToDouble() method.
  3. We print the result to standard output.

Dart Program

void main() {
  int num1 = 5;
  double doubleNum1 = num1.ceilToDouble();
  print('Double value of $num1: $doubleNum1');
}

Output

Double value of 5: 5

2 Convert a negative integer to double

In this example,

  1. We assign the value -3 to the integer variable num2.
  2. We convert num2 to a double using the ceilToDouble() method.
  3. We print the result to standard output.

Dart Program

void main() {
  int num2 = -3;
  double doubleNum2 = num2.ceilToDouble();
  print('Double value of $num2: $doubleNum2');
}

Output

Double value of -3: -3

3 Convert a positive integer to double

In this example,

  1. We assign the value 10 to the integer variable num3.
  2. We convert num3 to a double using the ceilToDouble() method.
  3. We print the result to standard output.

Dart Program

void main() {
  int num3 = 10;
  double doubleNum3 = num3.ceilToDouble();
  print('Double value of $num3: $doubleNum3');
}

Output

Double value of 10: 10

Summary

In this Dart tutorial, we learned about ceilToDouble() method of int: the syntax and few working examples with output and detailed explanation for each example.