The answer fits, but the product overflows
A large equilateral triangle showed how multiplication can exceed the numeric range before the square root has a chance to reduce it.

The triangle became infinite
I checked the area of an equilateral triangle with side length 1e100 in a short JavaScript calculation. Multiplying out Heron’s formula before taking the square root returned Infinity.
The triangle might seem too large, but its area from the equilateral formula is approximately 4.33e199. That lies within the finite positive range of JavaScript’s Number.
An article about intermediate overflow in large-triangle calculations prompted this separate Node.js example at the same scale. I did not reproduce its C++ timings or validate its complete algorithms.
The interesting distinction is between an answer too large to represent and overflowing before reaching an answer that would fit.
The square root was going to make the quantity smaller. The preceding multiplication ran out of room first.
Four quantities before the root
Heron’s formula takes the square root of s(s−a)(s−b)(s−c), where s is half the perimeter. For an equilateral triangle, the four factors become 1.5a, 0.5a, 0.5a, and 0.5a.
For a equal to 1e100, the product inside the root is roughly 1.875e399 in real arithmetic. It is much larger than the final area because we first construct the square of that area.
MDN gives Number.MAX_VALUE as approximately 1.8e308. Larger values are represented as Infinity and lose their original value. This multiplication crosses that boundary before the square root.
Taking the square root of Infinity cannot recover the magnitude lost earlier. The mathematical expression is valid, while an intermediate quantity in its execution exceeds the available range.
In the calculation, both the direct radicand and final result were Infinity. Looking only at the return value leaves another investigation: which operation overflowed first?
Reading the final mathematical expression and following the computer’s intermediate steps briefly become different activities.
Calculate small, then restore the scale
For this one equilateral case, we can first calculate the area with side length 1: approximately 0.4330127. Multiplying by the original side length a twice restores the area’s scale.
That ordering returned approximately 4.330127e199 in Node.js. At the same input scale, avoiding the direct product of four large factors produced a finite value.
One case does not validate an implementation for every triangle. Accuracy near degenerate shapes and whether inputs form a valid triangle remain separate questions. I did not compare execution speed.
Rescaling also cannot fix a final answer that is itself too large. With side length 1e200, the equilateral area is on the order of 1e400. Number cannot hold that result as a finite value.
The route to the return value
What I want to keep from this calculation is a question rather than a universal replacement function. After establishing that the answer fits, what do we calculate on the way to it?
A familiar order of multiplication and square root is easy to accept when translating a formula into code, especially after checking only small examples. Equivalent expressions can still construct intermediate quantities of different sizes.
I return to the Infinity at the end. This time I would open up the value passed into the square root first. The answer had room; the route to it had already overflowed.

