hasDecimals property

  1. @useResult
bool get hasDecimals

Returns true if this double has a non-zero fractional part.

Example:

15.5.hasDecimals; // true
15.0.hasDecimals; // false
15.00.hasDecimals; // false

Implementation

@useResult
bool get hasDecimals {
  if (isNaN || isInfinite) {
    return false;
  }

  return this % 1 != 0;
}