kelvinToCelsius static method

double kelvinToCelsius(
  1. double kelvin
)

Converts a temperature from Kelvin to Celsius.

Formula: C = K - 273.15

Parameters:

  • kelvin: The temperature in Kelvin.

Returns: The converted temperature in degrees Celsius.

Throws ArgumentError if the input Kelvin temperature is negative, as temperatures below 0 Kelvin are physically impossible.

Implementation

static double kelvinToCelsius(double kelvin) {
  if (kelvin < 0) {
    throw ArgumentError(
      'Kelvin temperature cannot be negative (below absolute zero).',
    );
  }
  return kelvin - 273.15;
}