clamp method

  1. @override
Number clamp(
  1. dynamic lowerLimit,
  2. dynamic upperLimit
)
override

Returns a Complex number whose real portion has been clamped to within lowerLimit and upperLimit and whose imaginary portion is the same as the imaginary value in this Complex number.

Implementation

@override
Number clamp(dynamic lowerLimit, dynamic upperLimit) {
  final clampedReal = real.clamp(lowerLimit, upperLimit) as Real;
  if (clampedReal.toDouble() == 0) return imaginary.value.toDouble() == 0 ? Integer.zero : imaginary;
  return Complex(clampedReal, imaginary);
}