zaagan
7/12/2019 - 5:37 AM

Dart Numbers

Dart Numbers

/*********  Number *********/
/*  subtypes of num : int and double  */
/*  Integers (64 bits max)
    Values On Dart VM :-2^63 to 2^63 - 1
    Value on Compiled JS : -2^53 to 2^53 - 1
*/
var year = 1991;
/*  Explicit declaration */
int age = 28;

/* doubles  (64 bits precision) */
var height = 6.2;
double z = 1; // (Dart 2.1) Eqv to double z = 1.0


/********* Properties ********
  double points = 45.23;
    
  points.hashCode // 295564923
  points.isFinite // true
  points.isInfinite // false
  points.isNaN // false
  points.isNegative // false
  
  (isEven & isOdd : Only in integer types)
  int num = 4;
  num.isEven   // true
  num.isOdd  // false
    
  num.sign  // 1
  Returns -1, 0 or 1 depending on 
  the sign and numerical value of the number
*/
  
/********* Methods ********
    
  double numDouble = -4.4523;
  
  int num = 4;
  num.toDouble() // 4 (In Double)
  
  numDouble.toInt()  // -4 (Integer)
  numDouble.abs()  // 4.4523 (Absolute value)
  numDouble.ceil() // -4
  numDouble.compareTo(num) // -1
  numDouble.truncate() // -4
  numDouble.floor() // -5 (Next greatest integer)
  numDouble.round() // -4 (Rouded to the nearest)
  
  var numToString = numDouble.toString();
  numToString is String // true
  
  double amount = 4;
  amount.remainder(2) // 0 (Remainder of a division)
  amount.toDouble() // 4 (To Double)
  
*/