percentOf method

double percentOf(
  1. num total
)

Calculates the percentage this number represents of total.

Example:

25.percentOf(100); // 25.0

Implementation

double percentOf(num total) {
  if (total == 0) return 0.0;
  return (this / total) * 100;
}