Significant figures (also known as "sig figs") are the digits in a number that carry meaningful contributions to its measurement resolution. In science and engineering, precision is everything. Significant figures help us communicate how certain we are about a measurement.
The Core Rules of Significant Figures
Non-zero digits: All digits from 1-9 are always significant. (e.g., 456 has 3 sig figs).
Captive Zeros: Zeros between non-zero digits are significant. (e.g., 101 has 3 sig figs).
Leading Zeros: Zeros at the beginning of a decimal number are NOT significant; they are just placeholders. (e.g., 0.005 has 1 sig fig).
Trailing Zeros: Zeros at the end of a number are significant ONLY if there is a decimal point. (e.g., 150.0 has 4 sig figs, but 150 usually has 2).
Realistic Example:
Suppose you measure a chemical compound weighing 0.04050 grams.
The first two zeros are leading (not significant).
The 4 and 5 are significant.
The zero between 4 and 5 is captive (significant).
The trailing zero is significant because there is a decimal point.
Total: 4 Significant Figures.
How to Round Significant Figures
Rounding to significant figures is different from rounding to decimal places. You start counting from the first non-zero digit. If you need to round 1,234 to 2 significant figures, you look at the first two digits (1 and 2). Since the third digit is 3 (less than 5), it becomes 1,200.
Importance in Calculations
When multiplying or dividing, your final answer cannot have more significant figures than the measurement with the fewest significant figures. This prevents the "illusion of precision" where a calculator provides 10 decimal places even though the original measurement was a rough estimate.
function calculateSigFigs() {
var input = document.getElementById("inputNumber").value.trim();
var roundTo = document.getElementById("roundTo").value;
var resultDiv = document.getElementById("results");
if (input === "" || isNaN(parseFloat(input))) {
resultDiv.style.display = "none";
return;
}
resultDiv.style.display = "block";
// Count Sig Figs logic
var count = 0;
var cleanNum = input.replace(/^-/, ""); // Remove negative sign
var hasDecimal = cleanNum.indexOf(".") !== -1;
document.getElementById("hasDecimal").innerText = hasDecimal ? "Yes" : "No";
var sigFigPattern;
if (hasDecimal) {
// Rule: Remove leading zeros, count remaining digits
var temp = cleanNum.replace(".", "");
var firstNonZero = temp.search(/[1-9]/);
if (firstNonZero === -1) {
count = 0; // Purely zeros like 0.00
} else {
count = temp.substring(firstNonZero).length;
}
} else {
// Rule: Remove leading and trailing zeros
var temp = cleanNum.replace(/^0+/, "");
temp = temp.replace(/0+$/, "");
count = temp.length;
}
document.getElementById("sigCount").innerText = count;
// Scientific Notation
var numValue = parseFloat(input);
document.getElementById("sciNotation").innerText = numValue.toExponential();
// Rounding Logic
var roundArea = document.getElementById("roundingResult");
if (roundTo && roundTo > 0) {
roundArea.style.display = "block";
var rounded = numValue.toPrecision(parseInt(roundTo));
// Remove trailing zeros added by toPrecision if we want a clean look,
// but scientific notation is safer for sig figs
document.getElementById("roundedVal").innerText = rounded;
} else {
roundArea.style.display = "none";
}
}