I have to create a function where I need to square values. I am told that even if the initial value is not too big or is not too small, the value squared might still overflow (returns inf
) or underflow (returns 0
), and I need to figure out how to prevent that.
My problem is I do not even understand what numbers can cause an overflow when squared when the number itself is not too large.
I thought it might be for the not too small numbers, e.g. 1/3
with repeating decimal numbers, but MATLAB just turns that into 0.3333
.
Can someone give me an example of such a number or explain what kind of numbers would cause this?