Range of numerical values
Ältere Kommentare anzeigen
What range of numerical values can be entered in MATLAB R2021a?
1 Kommentar
John D'Errico
am 28 Aug. 2021
Bearbeitet: John D'Errico
am 28 Aug. 2021
The tag was:
Please don't use tags to ask a question.
Antworten (1)
KSSV
am 28 Aug. 2021
0 Stimmen
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 Kommentare
dpb
am 28 Aug. 2021
<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'))
log2(eps(realmin('single')))
log2(realmin('double'))
log2(eps(realmin('double')))
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 .
Kategorien
Mehr zu Logical finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!