conversion of double to int
19 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
SNEHA P S
am 21 Jul. 2017
Kommentiert: Jan
am 21 Jul. 2017
i had an array of 1*10 double named Q(i). I want to find modulo function of these 10 values with 256. But am getting wrong answers. May be its the problem of types. Will you please help me to solve?
5 Kommentare
Walter Roberson
am 21 Jul. 2017
Give the command
format long g
And then display the Q value again
Akzeptierte Antwort
Walter Roberson
am 21 Jul. 2017
2^53 = 9007199254740992 is the largest integer expressed in double precision that you can reliably take mod() 10 of. After that, the difference between adjacent representable double precision numbers becomes more than 1.
You can extend the range by using uint64(), allowing you to get to 18446744073709551615 . Beyond that you would need to use the Symbolic Toolbox, or use one of the extended precision File Exchange contributions.
2 Kommentare
Jan
am 21 Jul. 2017
@SNEHA P S: Then compare the two values:
Q(7) - 4.078e+09
Note that the short format for the command window does not let you distinguish 4078000000 and 4078000001 or 4077999999.
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Logical finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!