Electrical Energy Calculator
Calculate electricity use from power and duration, or constant DC voltage and current. Compare energy use over different operating times in watt-hours, kilowatt-hours and joules.
Open toolInspection needs JavaScript. If it does not load, the explanation, formulas and examples below remain available.
Decode half, single and double precision values into sign, exponent and fraction bits, with the exact stored value and its rounding error.
Choose the format: half (16-bit), single (32-bit, C float) or double (64-bit, C double and JavaScript numbers).
Choose whether you are entering a decimal number or the stored bit pattern in hex, then type it. The tool starts with 0.1.
Read the pattern, the class and the fields. The stored value shows exactly what the float equals, and the rounding error shows how far that is from what you typed.
Select any bit in the grid to flip it and see the effect on the value. The input switches to the hex pattern.
Copy the pattern or all results. Reset restores the starting example, format and input type.
A binary floating-point number stores a sign, an exponent and a fraction. For normal numbers the value is (−1)^sign × 2^exponent × 1.fraction. The leading 1 is implied and not stored, which gains one bit of precision. Half, single and double precision have 11, 24 and 53 significant bits.
The exponent is stored with a bias (15, 127 or 1023), so the field is an unsigned number. All-zero and all-one exponent fields are reserved. All zeros with a zero fraction is ±0; with a non-zero fraction it is a subnormal number, which fills the gap near zero with reduced precision. All ones is ±infinity, or NaN when the fraction is non-zero.
Most decimal fractions, including 0.1, have no finite binary expansion, so they are rounded to the nearest representable value; exact ties go to the value with an even last bit. The stored value of 0.1 in single precision is 0.100000001490116119384765625. Printing the shortest decimal that rounds back to the same float gives 0.1 again, which is why the error is easy to miss.
The spacing between neighbouring floats (one ULP) doubles at each power of two. In single precision, whole numbers above 16,777,216 (2^24) can no longer all be stored. In double precision the same limit is 2^53, the safe-integer limit of JavaScript.
Values beyond the largest finite float round to infinity: for half precision that happens from 65,520 upward, although the largest finite value is 65,504. Values no larger than half of the smallest subnormal round to zero (an exact half is a tie and goes to the even value, zero).
Limitations: this tool uses only the default rounding (round to nearest, ties to even). It does not cover decimal floating-point formats, 128-bit, bfloat16 or 80-bit extended formats, and it does not do arithmetic between floats. NaN input is stored as the standard quiet NaN; other NaN payloads can be entered as hex.
Bit patterns are shown with the most significant bit first, as a debugger shows a value held in a register. Memory dumps of little-endian processors list the bytes in the reverse order.
Normal: x = (−1)^S × 2^(E − bias) × (1 + T / 2^(p−1))
Subnormal: x = (−1)^S × 2^(1 − bias) × (T / 2^(p−1))
Parameters: half: p = 11, bias = 15; single: p = 24, bias = 127; double: p = 53, bias = 1023
Spacing: ULP = 2^(e − p + 1)
Rounding error: stored value − entered value
Overflow threshold: 2^emax × (2 − 2^−p) (rounds to infinity)
0.1 as single precision (binary32): 0x3DCCCCCD; stored 0.100000001490116119384765625; error +1.490116119384765625e-9. Sign 0, exponent 123 − 127 = −4, fraction 0x4CCCCD. The last bit rounded up.
0.1 as double precision (binary64): 0x3FB999999999999A; stored 0.1000000000000000055511151231257827021181583404541015625. The same repeating pattern 1001…, with 29 more bits.
16777217 as single precision: 0x4B800000; stored 16777216; error -1. Above 2^24 the spacing is 2. The tie goes to the even significand.
65520 as half precision: infinity (0x7C00). A common surprise. 65520 is halfway between 65504 and 65536, ties go to even, and 65536 is beyond the format, so the result is infinity.
pattern 0x00000001 as single precision: subnormal; stored 1.40129846432481707092372958328991613128026194187651577175706828388979108268586060148663818836212158203125e-45; shortest 1e-45. The smallest positive single-precision value, 2^-149.
IEEE 754-2019: Standard for Floating-Point Arithmetic
Goldberg: What Every Computer Scientist Should Know About Floating-Point Arithmetic
Available now
Calculate electricity use from power and duration, or constant DC voltage and current. Compare energy use over different operating times in watt-hours, kilowatt-hours and joules.
Open tool →Available now
Add up to 20 resistors in series using Ω, kΩ or MΩ for circuit analysis and electricity calculations, with a diagram and running total.
Open tool →Available now
Convert absolute temperatures between Celsius, Fahrenheit and kelvin.
Open tool →Nice audio board working as expected.
Given the fact that this was my first purchase and I made it thinking I was buying genuine Yihua products, this has been a setback. I received a lesser known OEM brand called MYTO and while both the products seem to be similar from appearance, my real contention is the quality and quantity of the brass wool. On top of that not informing the customer about the unavailability of the Yihua product and instead sending a product from a different brand is also antagonising. Henceforth, I might just have to think twice before ordering from ThinkRobotics.
TOF MINIF Range Sensor - UART TOF Time-of-Flight Laser Range Sensor
We are disappointed with our recent order experience. We clearly communicated our requirement for 433 MHz antennas on WhatsApp, but the issue remains unresolved. We have been following up for more than 10 days and are still waiting for a proper refund resolution.
As a regular B2B customer, we expected better support. This experience has affected our trust in ThinkRobotics, and we may have to consider other suppliers for future purchases. We request a fair and prompt refund.
Anodised Aluminium Cup Head Washers (Pack of 10)