Hi,
I'm supposed to convert the following real numbers into exponent mantissa form:
a = 789.34
b = 0.0001
c = 400000000000
My first question is: what does exponent mantissa form mean? I've read something about binary online but I doubt that that's what we're supposed to do in this exercise.
My second question is how do I convert the numbers above into exponent mantissa form using matlab?
Any help is greatly appreciated!
Many thanks,
Dobs

回答 (1 件)

James Tursa
James Tursa 2021 年 10 月 26 日
編集済み: James Tursa 2021 年 10 月 26 日

1 投票

Without seeing the actual wording of the assignment, I would assume this simply means "floating point notation". E.g.,
123.456 can be written 1.23456 x 10^2 or 1.23456e2
.0123456 can be written 1.23456 x 10^-2 or 1.23456e-2
You can use lowercase e or uppercase E for the exponent. What is the actual wording of the assignment?

6 件のコメント

Dobs
Dobs 2021 年 10 月 26 日
It just says "Write the following real numbers in exponent-mantissa form" and it's an introduction to matlab class, in case that helps.
So how do I get matlab to write 123.456 as 1.23456x10^2 ?
Walter Roberson
Walter Roberson 2021 年 10 月 26 日
See fprintf %e format
Dobs
Dobs 2021 年 10 月 26 日
Unfortunately this doesn't seem to work, it just says "not enough input arguments" :/
Jan
Jan 2021 年 10 月 26 日
Walter's suggestion to "see" means:
doc fprintf
% Search for the %e format there
and not copy&paste "fprintf %e".
James Tursa
James Tursa 2021 年 10 月 26 日
編集済み: James Tursa 2021 年 10 月 26 日
Please show us what you tried. We can't guess what you did wrong. E.g., to use fprintf:
x = 123.456;
fprintf('%e \n',x);
The %e is the exponential notation format to use to print x, and the \n is a newline so the curser will move to the next line after printing x.
Steven Lord
Steven Lord 2021 年 10 月 26 日
The log2 function may also be of use.

サインインしてコメントする。

カテゴリ

製品

リリース

R2021b

質問済み:

2021 年 10 月 26 日

コメント済み:

2021 年 10 月 26 日

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by