celsiusToKelvin static method

double celsiusToKelvin(
  1. double celsius
)

Converts a temperature from Celsius to Kelvin.

Formula: K = C + 273.15

Parameters:

  • celsius: The temperature in degrees Celsius.

Returns: The converted temperature in Kelvin.

Throws ArgumentError if the resulting Kelvin temperature would be below absolute zero (0 Kelvin / -273.15 Celsius).

Implementation

static double celsiusToKelvin(double celsius) {
  final double kelvin = celsius + 273.15;
  if (kelvin < 0) {
    throw ArgumentError(
      'Resulting Kelvin temperature cannot be below 0K (absolute zero).',
    );
  }
  return kelvin;
}