Method and source check
Last checked:
Automated source and implementation review, including worked examples and documented numerical limits. This review does not provide professional advice or specialist approval.
Method
At constant power, multiply watts by elapsed hours for watt-hours. Divide watt-hours by a positive duration for watts. An optional energy charge is kWh × the user-entered price per kWh.
Wh = W × hours
W = Wh / hours
kWh = Wh / 1000
energy-only charge = kWh × entered price per kWh
Variables and units
- W
- constant power in watts
- Wh
- energy in watt-hours
- hours
- duration converted from entered unit
- rate
- optional price per kWh in the user’s chosen currency
Worked example
At constant 100 W for five hours, energy is 500 Wh = 0.5 kWh. At an entered price of 0.12 per kWh, the energy-only charge is 0.06 in the entered currency.
Limitations
Energy, power, duration, and the optional entered-currency energy charge retain floating-point calculation precision; the UI displays up to six significant digits.
- Wh-to-W requires a positive duration. Device examples are hypothetical constant-power cases; energy-only cost excludes all other bill charges.
- The form schema rejects derived overflow and unsupported numerical combinations before showing results; the calculation helper expects schema-validated input.
- 100W×5h → 500Wh
- 500Wh/5h → 100W
- 500Wh/0h rejected
- 100W×1min → about 1.667Wh before display rounding
- 1e308 W × 24 hours is rejected on power; 500 Wh ÷ 1e-320 seconds is rejected on energy; an unrepresentable converted duration is rejected on time.