Weight to Mass Calculator: Convert and Understand
:root {
–primary-color: #004a99;
–success-color: #28a745;
–background-color: #f8f9fa;
–text-color: #333;
–secondary-text-color: #6c757d;
–border-color: #dee2e6;
–card-background: #ffffff;
–shadow: 0 4px 8px rgba(0,0,0,0.05);
}
body {
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
background-color: var(–background-color);
color: var(–text-color);
margin: 0;
padding: 20px;
display: flex;
justify-content: center;
flex-direction: column;
align-items: center;
}
.container {
max-width: 980px;
width: 100%;
background-color: var(–card-background);
padding: 30px;
border-radius: 8px;
box-shadow: var(–shadow);
margin-bottom: 40px;
}
h1, h2, h3 {
color: var(–primary-color);
text-align: center;
}
h1 {
font-size: 2.5em;
margin-bottom: 20px;
}
h2 {
font-size: 2em;
margin-top: 40px;
margin-bottom: 20px;
border-bottom: 2px solid var(–primary-color);
padding-bottom: 10px;
}
h3 {
font-size: 1.5em;
margin-top: 30px;
margin-bottom: 15px;
}
.sub-heading {
font-size: 1.2em;
color: var(–secondary-text-color);
text-align: center;
margin-bottom: 30px;
}
.loan-calc-container {
background-color: var(–card-background);
padding: 25px;
border-radius: 8px;
box-shadow: var(–shadow);
margin-bottom: 30px;
}
.input-group {
margin-bottom: 20px;
text-align: left;
}
.input-group label {
display: block;
margin-bottom: 8px;
font-weight: 600;
color: var(–primary-color);
}
.input-group input[type="number"],
.input-group select {
width: calc(100% – 20px);
padding: 10px;
border: 1px solid var(–border-color);
border-radius: 5px;
font-size: 1em;
box-sizing: border-box;
}
.input-group .helper-text {
font-size: 0.85em;
color: var(–secondary-text-color);
margin-top: 5px;
display: block;
}
.input-group .error-message {
color: #dc3545;
font-size: 0.85em;
margin-top: 5px;
height: 1.2em;
display: block;
}
.button-group {
display: flex;
gap: 15px;
justify-content: center;
margin-top: 25px;
}
button {
padding: 12px 25px;
border: none;
border-radius: 5px;
font-size: 1em;
font-weight: 600;
cursor: pointer;
transition: background-color 0.3s ease;
}
.btn-calculate {
background-color: var(–primary-color);
color: white;
}
.btn-calculate:hover {
background-color: #003366;
}
.btn-reset {
background-color: var(–secondary-text-color);
color: white;
}
.btn-reset:hover {
background-color: #495057;
}
.btn-copy {
background-color: #6c757d;
color: white;
}
.btn-copy:hover {
background-color: #5a6268;
}
#results-container {
background-color: var(–primary-color);
color: white;
padding: 25px;
border-radius: 8px;
margin-top: 30px;
text-align: center;
box-shadow: var(–shadow);
}
#results-container h3 {
color: white;
margin-bottom: 15px;
}
#main-result {
font-size: 2.8em;
font-weight: bold;
margin-bottom: 10px;
}
#results-container .formula-explanation {
font-size: 0.95em;
margin-bottom: 20px;
opacity: 0.9;
}
.intermediate-results {
display: flex;
justify-content: space-around;
flex-wrap: wrap;
margin-top: 20px;
border-top: 1px solid rgba(255,255,255,0.2);
padding-top: 20px;
}
.intermediate-result-item {
text-align: center;
margin: 10px;
}
.intermediate-result-item span {
display: block;
font-size: 1.2em;
font-weight: bold;
}
.intermediate-result-item p {
font-size: 0.9em;
margin: 0;
opacity: 0.9;
}
canvas {
max-width: 100%;
height: auto;
margin-top: 30px;
border: 1px solid var(–border-color);
border-radius: 5px;
}
table {
width: 100%;
border-collapse: collapse;
margin-top: 30px;
box-shadow: var(–shadow);
}
th, td {
padding: 12px 15px;
text-align: left;
border-bottom: 1px solid var(–border-color);
}
thead {
background-color: var(–primary-color);
color: white;
}
tbody tr:nth-child(even) {
background-color: #e9ecef;
}
caption {
font-size: 1.1em;
font-weight: bold;
color: var(–text-color);
margin-bottom: 10px;
text-align: left;
}
.article-content {
text-align: left;
max-width: 980px;
margin-top: 40px;
}
.article-content p, .article-content ul, .article-content ol {
line-height: 1.7;
margin-bottom: 20px;
font-size: 1.1em;
}
.article-content a {
color: var(–primary-color);
text-decoration: none;
font-weight: 500;
}
.article-content a:hover {
text-decoration: underline;
}
.faq-item {
margin-bottom: 20px;
border-left: 4px solid var(–primary-color);
padding-left: 15px;
}
.faq-item strong {
display: block;
font-size: 1.1em;
margin-bottom: 5px;
color: var(–primary-color);
}
.related-links ul {
list-style: none;
padding: 0;
}
.related-links li {
margin-bottom: 15px;
}
.related-links a {
font-weight: 600;
}
.related-links span {
font-size: 0.9em;
color: var(–secondary-text-color);
display: block;
margin-top: 5px;
}
@media (max-width: 768px) {
h1 { font-size: 2em; }
h2 { font-size: 1.7em; }
.container, .loan-calc-container { padding: 20px; }
.button-group { flex-direction: column; align-items: center; }
.intermediate-results { flex-direction: column; align-items: center; }
.intermediate-result-item { margin: 10px 0; }
}
Weight to Mass Calculator
Accurately convert weight measurements into mass using gravitational acceleration.
Calculation Results
—
Mass = Weight / Gravitational Acceleration
Gravitational Acceleration vs. Mass
Chart shows mass generated at different gravitational accelerations.
Weight to Mass Conversion Factors
| Weight Unit |
Equivalent Standard Earth Weight (N) |
Gravitational Accel. (m/s²) |
Conversion to Mass (kg) |
What is Weight to Mass Calculation?
The weight to mass calculation is a fundamental process in physics and engineering used to determine an object's mass from its weight, which is the force exerted on it by gravity. While often used interchangeably in everyday language, weight and mass are distinct physical properties. Mass is an intrinsic property of matter, representing the amount of "stuff" in an object, and it remains constant regardless of location. Weight, on the other hand, is a force that depends on both an object's mass and the strength of the gravitational field it's in. A weight to mass calculation allows us to isolate this intrinsic property (mass) from the variable influence of gravity.
Who should use it? This calculation is crucial for students learning physics, engineers designing structures or vehicles that will operate in different gravitational environments, scientists conducting experiments, and anyone needing precise scientific measurements. It's particularly important when dealing with spacecraft, astronauts, or even comparing measurements taken on different planets. Understanding the distinction is key for accurate scientific discourse and application.
Common misconceptions often revolve around the idea that weight and mass are the same. Many people think of "weight" in kilograms or pounds and assume it's mass. However, kilograms and pounds are units of mass. When we talk about "weighing" ourselves, we are technically measuring the force (weight) our body exerts on the scale, which is then calibrated to display our mass under Earth's standard gravity. A weight to mass calculation highlights this distinction, especially when dealing with units like Newtons (a unit of force) for weight.
Weight to Mass Calculation Formula and Mathematical Explanation
The core relationship between weight (W), mass (m), and gravitational acceleration (g) is defined by Newton's second law of motion, specifically applied to the force of gravity:
W = m × g
To perform a weight to mass calculation, we need to rearrange this formula to solve for mass (m):
m = W / g
This formula states that mass is equal to the weight (force) divided by the local gravitational acceleration. Let's break down the variables:
Variable Definitions for Weight to Mass Calculation
| Variable |
Meaning |
Unit |
Typical Range |
| m |
Mass |
Kilograms (kg), Pounds (lb), Slugs |
Varies widely; fundamental property. |
| W |
Weight (Force due to Gravity) |
Newtons (N), Pounds-force (lbf), Kilograms-force (kgf) |
Depends on mass and 'g'. On Earth, a 1kg mass has ~9.81 N weight. |
| g |
Gravitational Acceleration |
Meters per second squared (m/s²) |
~9.81 m/s² on Earth's surface; ~1.62 m/s² on the Moon; ~24.79 m/s² on Jupiter. |
The calculator simplifies this by allowing you to input your measured weight in common units (like Newtons or pounds-force) and the specific gravitational acceleration relevant to your location (or a standard value). It then outputs the mass in your desired unit (kilograms, pounds, or slugs). Special handling is included for units like kgf and lbf which are force units directly proportional to mass under standard Earth gravity (g ≈ 9.80665 m/s²). For example, if you have a weight of 100 kgf, it implies a mass of 100 kg under Earth's standard gravity.
Practical Examples (Real-World Use Cases)
Understanding the weight to mass calculation becomes clearer with practical scenarios:
Example 1: Astronaut on the Moon
An astronaut's space suit and equipment exert a force (weight) of 1200 Newtons on the Moon's surface. The Moon's gravitational acceleration is approximately 1.62 m/s². We want to find the astronaut's total mass.
- Input Weight (W): 1200 N
- Gravitational Acceleration (g): 1.62 m/s²
- Target Mass Unit: kg
Using the formula m = W / g:
m = 1200 N / 1.62 m/s² ≈ 740.74 kg
Interpretation: Even though the astronaut *weighs* 1200 N on the Moon (which feels much lighter than on Earth), their intrinsic mass is approximately 740.74 kg. This mass would exert a force of about 7263 N on Earth (740.74 kg * 9.81 m/s²).
Example 2: Everyday Object on Earth vs. Jupiter
A rock has a measured weight of 49.05 Newtons on Earth's surface (where g ≈ 9.81 m/s²). We want to find its mass and then calculate how much it would weigh on Jupiter (where g ≈ 24.79 m/s²).
- Input Weight (W): 49.05 N
- Gravitational Acceleration (g): 9.81 m/s² (for Earth)
- Target Mass Unit: kg
First, calculate the mass:
m = 49.05 N / 9.81 m/s² = 5.00 kg
Now, calculate the weight on Jupiter using the calculated mass:
W_Jupiter = m × g_Jupiter = 5.00 kg × 24.79 m/s² = 123.95 N
Interpretation: The rock has a constant mass of 5.00 kg. On Earth, this mass results in a weight of 49.05 N. On Jupiter, the same 5.00 kg mass results in a significantly higher weight of 123.95 N due to Jupiter's stronger gravity. This demonstrates why weight to mass calculation is vital for understanding true matter content.
How to Use This Weight to Mass Calculator
Our weight to mass calculator is designed for simplicity and accuracy. Follow these steps:
- Enter Weight Value: Input the numerical value of the weight you have measured.
- Select Weight Unit: Choose the unit corresponding to your input value. Common options include Newtons (N) for force, or specialized units like Pounds-force (lbf) and Kilograms-force (kgf). Select "Standard Earth Gravity (N/lbf)" if your value already implies force under Earth's standard gravity.
- Input Gravitational Acceleration: Enter the value for gravitational acceleration (in m/s²) at the location where the weight was measured. If you don't know the specific value, use the default of 9.81 m/s², which represents Earth's average surface gravity.
- Choose Target Mass Unit: Select the desired unit for the output mass: Kilograms (kg), Pounds (lb), or Slugs.
- Calculate: Click the "Calculate Mass" button.
How to read results:
- The Primary Result will display your calculated mass in the target unit.
- Intermediate Values show your input weight, the gravitational acceleration used, and the calculated mass in kilograms (often useful as a reference).
- The Formula Explanation clarifies the simple division used: Mass = Weight / Gravity.
- The Chart visually represents how your object's mass would contribute to weight across a range of gravitational forces.
- The Table provides conversion factors for different weight units to better understand the relationships.
Decision-making guidance: Use the results to understand the intrinsic amount of matter an object possesses, irrespective of its location. This is critical for scientific accuracy, comparing measurements across different celestial bodies, or ensuring proper material specifications in engineering contexts. For example, if designing a component that needs to withstand a certain force, knowing its mass and the intended 'g' environment is crucial.
Key Factors That Affect Weight to Mass Calculation Results
While the core formula (m = W/g) is straightforward, several factors influence the accuracy and interpretation of a weight to mass calculation:
- Accuracy of Weight Measurement: The precision of your initial weight reading is paramount. If the force measurement is off, the calculated mass will be proportionally inaccurate. This requires using calibrated instruments.
- Precision of Gravitational Acceleration (g): Gravity varies slightly across Earth's surface due to altitude, latitude, and local geological density. For highly precise work, using the exact local 'g' value is necessary. Standard values (like 9.81 m/s²) are approximations.
- Choice of Units: Using consistent and correct units is vital. Mixing metric and imperial units without proper conversion factors will lead to erroneous results. Our calculator handles standard conversions, but understanding the underlying units (force vs. mass) is key.
- Definition of "Weight" Input: Some systems might provide "weight" in units like kg or lbs, which are inherently mass units under standard gravity. The calculator accounts for this by allowing specific force units (N, lbf, kgf) and noting that "Standard Earth Gravity" inputs already incorporate Earth's 'g'. A direct input of "10 kg" as weight would be incorrect physics.
- Buoyancy Effects: In fluid environments (like air or water), objects experience an upward buoyant force. The measured "weight" might be the apparent weight (actual weight minus buoyant force). For true mass calculation, you'd ideally measure weight in a vacuum or account for buoyancy.
- Relativistic Effects: At speeds approaching the speed of light, mass increases relative to a stationary observer. This calculator operates within the realm of classical mechanics and does not account for relativistic mass increase, which is negligible for everyday objects and speeds.
Frequently Asked Questions (FAQ)
Q1: Is weight the same as mass?
No. Mass is the amount of matter in an object and is constant. Weight is the force of gravity acting on that mass, and it changes depending on the gravitational field.
Q2: Why does the calculator ask for gravitational acceleration?
Because weight is directly dependent on gravity (Weight = Mass × Gravity). To find the intrinsic mass from a measured weight, you must know the gravitational force (g) that produced that weight.
Q3: What is the standard gravitational acceleration on Earth?
The standard value is defined as 9.80665 m/s². For most practical purposes, 9.81 m/s² is used.
Q4: What happens if I measure my weight on the Moon and use Earth's gravity?
Your calculated mass will be incorrect. You must use the gravitational acceleration specific to the location where the weight was measured (e.g., ~1.62 m/s² for the Moon).
Q5: My weight is in 'kg'. Should I enter it as weight or mass?
In everyday terms, when people say "weight in kg", they usually mean mass. However, for physics calculations, 'kg' is a unit of mass. If you have a force measured in Newtons (N) or Pounds-force (lbf), use those. If your weight is given as '10 kgf' (kilogram-force), this directly implies a mass of 10 kg under standard Earth gravity, so you can input 10 kgf as the weight unit.
Q6: What is a 'slug'?
The slug is the imperial unit of mass. If an object has a weight of 1 pound-force (lbf) on Earth, its mass is approximately 1 slug. 1 slug ≈ 14.59 kg.
Q7: How does this relate to density?
Mass is a component of density (Density = Mass / Volume). Once you accurately calculate the mass of an object using this calculator, you can then determine its density if you also know its volume.
Q8: Can I use this calculator for relativistic speeds?
No. This calculator is based on classical Newtonian physics and is accurate for everyday speeds and masses. Relativistic effects become significant only at speeds approaching the speed of light.
var chartInstance = null; // Global variable for chart instance
function getElement(id) {
return document.getElementById(id);
}
function validateInput(value, id, errorMessageId, min = null, max = null) {
var errorElement = getElement(errorMessageId);
errorElement.textContent = ";
if (value === " || isNaN(parseFloat(value))) {
errorElement.textContent = 'Please enter a valid number.';
return false;
}
var numValue = parseFloat(value);
if (numValue < 0 && id !== 'gravityAcceleration') { // Allow positive gravity values, but weight must be non-negative
errorElement.textContent = 'Value cannot be negative.';
return false;
}
if (id === 'gravityAcceleration' && numValue <= 0) { // Gravity must be positive
errorElement.textContent = 'Gravitational acceleration must be positive.';
return false;
}
if (min !== null && numValue max) {
errorElement.textContent = `Value cannot exceed ${max}.`;
return false;
}
return true;
}
function calculateMass() {
var weightValueInput = getElement("weightValue");
var weightUnitSelect = getElement("weightUnit");
var gravityAccelerationInput = getElement("gravityAcceleration");
var targetUnitSelect = getElement("targetUnit");
var weightValue = weightValueInput.value.trim();
var weightUnit = weightUnitSelect.value;
var gravityAccelerationValue = gravityAccelerationInput.value.trim();
var targetUnit = targetUnitSelect.value;
var isValid = true;
if (!validateInput(weightValue, "weightValue", "weightValueError")) isValid = false;
if (!validateInput(gravityAccelerationValue, "gravityAcceleration", "gravityAccelerationError", 0.000001)) isValid = false; // Gravity must be positive
if (!isValid) {
hideResults();
return;
}
var wValue = parseFloat(weightValue);
var gValue = parseFloat(gravityAccelerationValue);
var weightInNewtons = 0;
var massInKg = 0;
// Convert input weight to Newtons for consistent calculation
if (weightUnit === "N") {
weightInNewtons = wValue;
} else if (weightUnit === "lbf") {
weightInNewtons = wValue * 4.44822; // 1 lbf = 4.44822 N
} else if (weightUnit === "kgf") {
weightInNewtons = wValue * 9.80665; // 1 kgf = 9.80665 N (standard gravity)
} else if (weightUnit === "N_standard") {
// Assumes the input N is already under standard Earth gravity
weightInNewtons = wValue;
// For display purposes, we'll use 9.81 for intermediate gravity if this is selected
if (gValue === 9.81) { // Only override if default is used
gValue = 9.80665;
}
} else if (weightUnit === "lbf_standard") {
// Assumes the input lbf is already under standard Earth gravity
weightInNewtons = wValue * 4.44822;
// For display purposes, we'll use 9.81 for intermediate gravity if this is selected
if (gValue === 9.81) { // Only override if default is used
gValue = 9.80665;
}
}
// Calculate mass in kg using the provided or standard gravity
// If unit was kgf or lbf, we've already converted to N based on standard gravity,
// but the calculation needs the *actual* g value for the location.
// The core formula m = W/g holds.
massInKg = weightInNewtons / gValue;
var finalMass = 0;
var finalMassUnitSymbol = ";
// Convert mass to the target unit
if (targetUnit === "kg") {
finalMass = massInKg;
finalMassUnitSymbol = 'kg';
} else if (targetUnit === "lb") {
finalMass = massInKg * 2.20462; // 1 kg = 2.20462 lb
finalMassUnitSymbol = 'lb';
} else if (targetUnit === "slug") {
finalMass = massInKg / 14.5939; // 1 slug = 14.5939 kg
finalMassUnitSymbol = 'slug';
}
// Calculate intermediate results
var intermediateMassStd = massInKg; // Mass in kg is always a good reference
var inputWeightDisplay = wValue.toFixed(2) + ' ' + weightUnit.replace('_standard', ");
var gravityDisplay = gValue.toFixed(2) + ' m/s²';
getElement("main-result").textContent = finalMass.toFixed(3) + ' ' + finalMassUnitSymbol;
getElement("intermediateWeight").textContent = inputWeightDisplay;
getElement("intermediateGravity").textContent = gravityDisplay;
getElement("intermediateMassStandard").textContent = intermediateMassStd.toFixed(3) + ' kg';
getElement("results-container").style.display = "block";
updateChart(gValue, massInKg);
updateTable(weightUnit, wValue, gValue, massInKg);
getElement("chart-container").style.display = "block";
getElement("table-container").style.display = "block";
}
function hideResults() {
getElement("results-container").style.display = "none";
getElement("chart-container").style.display = "none";
getElement("table-container").style.display = "none";
}
function resetCalculator() {
getElement("weightValue").value = "";
getElement("weightUnit").value = "N";
getElement("gravityAcceleration").value = "9.81";
getElement("targetUnit").value = "kg";
// Clear errors
getElement("weightValueError").textContent = ";
getElement("gravityAccelerationError").textContent = ";
hideResults();
if (chartInstance) {
chartInstance.destroy();
chartInstance = null;
}
}
function copyResults() {
var mainResult = getElement("main-result").textContent;
var intermediateWeight = getElement("intermediateWeight").textContent;
var intermediateGravity = getElement("intermediateGravity").textContent;
var intermediateMassStd = getElement("intermediateMassStandard").textContent;
var assumptions = "Key Assumptions:\n";
assumptions += "- Gravitational Acceleration: " + getElement("gravityAcceleration").value + " m/s²\n";
assumptions += "- Target Mass Unit: " + getElement("targetUnit").value + "\n";
var textToCopy = "Weight to Mass Calculation Results:\n";
textToCopy += "Main Result: " + mainResult + "\n";
textToCopy += "——————–\n";
textToCopy += "Intermediate Values:\n";
textToCopy += "- Input Weight: " + intermediateWeight + "\n";
textToCopy += "- Gravitational Acceleration Used: " + intermediateGravity + "\n";
textToCopy += "- Mass (Reference kg): " + intermediateMassStd + "\n";
textToCopy += "——————–\n";
textToCopy += assumptions;
// Use a temporary textarea to copy text
var textArea = document.createElement("textarea");
textArea.value = textToCopy;
textArea.style.position = "fixed";
textArea.style.left = "-9999px";
document.body.appendChild(textArea);
textArea.focus();
textArea.select();
try {
var successful = document.execCommand('copy');
var msg = successful ? 'Results copied!' : 'Copying failed';
// Optionally display a small notification
var notification = document.createElement('div');
notification.textContent = msg;
notification.style.cssText = 'position: fixed; top: 10px; right: 10px; background-color: var(–primary-color); color: white; padding: 10px; border-radius: 5px; z-index: 1000;';
document.body.appendChild(notification);
setTimeout(function() { notification.remove(); }, 2000);
} catch (err) {
console.error('Fallback: Oops, unable to copy', err);
}
document.body.removeChild(textArea);
}
function updateChart(currentG, currentMassKg) {
var ctx = getElement('massChart').getContext('2d');
// Clear previous chart if it exists
if (chartInstance) {
chartInstance.destroy();
}
var gravityValues = [0.1, 1.62, 9.81, 24.79, 3.71, 10.44]; // Example gravities: (low G, Moon, Earth, Jupiter, Mars, Saturn)
var labels = ['Very Low G', 'Moon', 'Earth', 'Jupiter', 'Mars', 'Saturn'];
var dataSeriesWeight = [];
for (var i = 0; i item.unit === weightUnit);
if (selectedUnitInfo) {
var massFromSelectedUnit = selectedUnitInfo.conversionToKg(weightValue, gravityValue);
// Use the user's specified gravity for the conversion if it's not a "standard" type
var effectiveG = (weightUnit === "kgf" || weightUnit === "N_standard" || weightUnit === "lbf_standard") ? selectedUnitInfo.equivG : gravityValue;
addTableRow(tableBody, selectedUnitInfo.label, selectedUnitInfo.equivWeightN.toFixed(3), effectiveG.toFixed(3), massFromSelectedUnit.toFixed(3));
}
// Add rows for common reference units, calculating their mass based on standard Earth gravity (9.80665 m/s²)
var standardG = 9.80665;
var commonUnits = [
{ label: "Newtons (N)", weightN: 1, calcMass: function(g){ return 1 / g; }},
{ label: "Pounds-force (lbf)", weightN: 4.44822, calcMass: function(g){ return (4.44822) / g; }},
{ label: "Kilograms-force (kgf)", weightN: standardG, calcMass: function(g){ return 1; }} // 1 kgf implies 1 kg mass
];
commonUnits.forEach(function(unit) {
// Calculate equivalent mass in kg for this unit, assuming standard Earth gravity
var massInKgRef = unit.calcMass(standardG);
// Calculate the equivalent weight in N on Earth for this mass
var earthWeightN = massInKgRef * standardG;
// Check if this row is already added (e.g., if user selected kgf)
var alreadyAdded = false;
if (selectedUnitInfo && selectedUnitInfo.unit === unit.label.split(' ')[0].toLowerCase() && selectedUnitInfo.unit !== 'n') { // Basic check for exact match
alreadyAdded = true;
}
if (!alreadyAdded) {
addTableRow(tableBody, unit.label, earthWeightN.toFixed(3), standardG.toFixed(3), massInKgRef.toFixed(3));
}
});
}
function addTableRow(tbody, weightUnitLabel, equivWeight, equivG, massKg) {
var row = tbody.insertRow();
var cell1 = row.insertCell(0);
var cell2 = row.insertCell(1);
var cell3 = row.insertCell(2);
var cell4 = row.insertCell(3);
cell1.textContent = weightUnitLabel;
cell2.textContent = equivWeight;
cell3.textContent = equivG;
cell4.textContent = massKg;
}
// Add event listeners for real-time updates
document.getElementById('weightValue').addEventListener('input', calculateMass);
document.getElementById('weightUnit').addEventListener('change', calculateMass);
document.getElementById('gravityAcceleration').addEventListener('input', calculateMass);
document.getElementById('targetUnit').addEventListener('change', calculateMass);
// Initial calculation on load if fields have default values (though they are cleared by reset)
// To ensure values are calculated when the page loads, uncomment the line below:
// calculateMass();