Conversion to single is out of range
Mostra commenti meno recenti
I have an algorithm prototyped in MATLAB that needs to match with the prodcution single precision C-code. I understand the limitations of single vs double and that MATLAB uses double precision internally. What I am struggling with is that the single() type in MATLAB apparently produces values that are out of range for IEEE 754, 32-bit single precision. This causes problems when comparing the output of MATLAB against the output of the C-code.
Check range of single in MATLAB
>> realmax('single')
ans =
single
3.4028e+38
>> realmin('single')
ans =
single
1.1755e-38
>> single(2.0e+39)
ans =
single
Inf
>> single(2.0e-39)
ans =
single
2.0000e-39
As you can see, single() of a small number outside of the valid range returns an invalid value.
Risposta accettata
Più risposte (0)
Categorie
Scopri di più su Logical in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!