temper 1.0.0 copy "temper: ^1.0.0" to clipboard
temper: ^1.0.0 copied to clipboard

Temper ==> Visionary Software Solutions Temperature me_sure_meant API.

example/temper_example.dart

import 'package:me_sure_meant/me_sure_meant.dart';
import 'package:temper/temper.dart';

void main() {
  final fahrenheit = 89.fahrenheit();
  final celsius = fahrenheit.toUnit(Celsius());
  assert(celsius == 31.6667.celsius());
  final kelvin = 20.celsius().toUnit(Kelvin.kelvin);
  assert(kelvin == 293.15.kelvin());

  /// An implementation aficionado might notice that these are different
  /// it turns out that although °F,°C, and K are all convertible to each other
  /// It is invalid to to attempt to add 2 temps by
  /// "convert to Kelvin, add, then turn back."
  /// Basically, the math doesn't work because of the +/- of constants.
  /// i.e. (1 °C + 500 °C) IS NOT EQUAL to (274.15 K + 773.15 K)
  /// I found this a bit subtle but it's fairly well known
  /// https://en.wikipedia.org/wiki/Conversion_of_scales_of_temperature#Converting_units_of_temperature_differences
  /// It's not insurmountable, one simply overrides the +/-.
  /// Still, worth noting.
  final mess = (10.kelvin() +
          42.fahrenheit() +
          Kelvins(crude(10), Kelvin.megakelvin) -
          30000.celsius())
      .toUnit(Fahrenheit());
  print(mess);
  assert(mess == 17945568.33.fahrenheit());
}
1
likes
160
points
22
downloads

Publisher

verified publishervisionary.software

Weekly Downloads

Temper ==> Visionary Software Solutions Temperature me_sure_meant API.

Repository

Documentation

API reference

License

GPL-3.0 (license)

Dependencies

me_sure_meant

More

Packages that depend on temper