What range of numerical values can be entered in MATLAB R2021a?

답변 (1개)

KSSV
KSSV 2021년 8월 28일

0 개 추천

Read about single and double floating point numbers.
Range of single: 2^(-126) to 2^(127)
Range of double: 2^(-1022) to 2^(1023).
If you use symbolic tool box, you can prescribe your required precision.

댓글 수: 2

dpb
dpb 2021년 8월 28일
<help/matlab/numeric-types> has all the various native data types and their ranges plus the various functions available that return information regarding them.
As far as the Q? buried in the tag (don't do that, by the way in future, not the purpose of a tag), inf is NOT the largest value that can be entered; inf is not actually a value but a flag that the value is greater or less than the (signed) range for a floating point variable and can only be generated by an operation such as 1/0, use of the builtin inf function or by casting from the hex respresentation. See <infinity-and-nan>.
The largest values are given by
>> realmax("double"), realmax('single')
ans =
1.7977e+308
ans =
single
3.4028e+38
>>
All this is in the documentation linked to above on data types. Also read up on IEEE-754 -- probably the most approachable in depth resource there is <Goldberg -- What Every Computer Scientist Should Know About Floating Point Arithmetic>>
The smallest magnitude numbers are not exactly what KSSV indicated.
log2(realmin('single'))
ans = single -126
log2(eps(realmin('single')))
ans = single -149
log2(realmin('double'))
ans = -1022
log2(eps(realmin('double')))
ans = -1074
The numbers between 2^-149 and 2^-126 (single precision) or 2^-1074 and 2^-1022 (double precision) are stored in a different format known as "denormalized numbers". The denormalized numbers are effectively fixed-point rather than floating point -- so in the case of single precision, a denormalized number would be an integer times 2^-149 and in the case of double precision, a denormalized number would be an integer times 2^-1074 .

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터File Exchange에서 Logical에 대해 자세히 알아보기

질문:

2021년 8월 28일

댓글:

2021년 8월 28일

Community Treasure Hunt

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

Start Hunting!

Translated by