MATLAB: Crazy, malformatted numbers as answer to simple equation.

bugengineering notationformatMATLABnot a bugsymbolic mathweird numbers

I'm doing work for an engineering course, and what seems to be a simple equation is becoming a big problem very quickly. Essentially, I multiply any number (except for 1) with a negative value for it's engineering notation by any symbol, and the answer I get is, in a word, strange. For instance, if I multiply 2e-6 by s, then I expect 2.0000e-06 * s as the answer. Instead I get (4722366482869645*s)/2361183241434822606848. I'll provide examples of the issue below.
>> syms s t;
>> % first example of strange answer
>> 2*10^(-6) * s
ans =
(4722366482869645*s)/2361183241434822606848
>> % second example of strange answer
>> 2e-6 * t
ans =
(4722366482869645*t)/2361183241434822606848
>> % conditions that do not reproduce the problem
>> 2e6*s
ans =
2000000*s
>> 1e-6*s
ans =
s/1000000
If I turn in any work with answers that look like this, it'll cost me a fair amount of points if not all of them. Is there anyway to get these answers to format correctly?

Best Answer

Oh, really, it'll cost you a lot of points? To turn in a mathematically correct answer?
When you type in a number like 2e-6, that number is not actually exactly representable as a floating point number. So MATLAB must approximate it in floating point, as a BINARY fraction, which will be a repeating binary. Then it passes that result to the symbolic toolbox, which turns it into a symbolic number, that represents the approximate value that was passed in!
You can force MATLAB to recognize 2e-6 as a symbolic constant however.
sym('2e-6') * s
ans =
0.000002*s
Or, you can learn to use vpa.
help vpa
Or both.