when I "str2num'110110111'" I received 110110111 as the answer
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
when I "str2num'110110111'" I received 110110111 as the answer.
Adding one more bit there I received 1.10...e+9 (or like that), the scientific notation, which I don't want. I tried and gathered that when the string exceeds 9 (or maybe 10) bits the function returns scientific notation as answer. Is there a way to make sure it returns the exact 'copy' in num form and NOT in scientific notation?
0 Kommentare
Antworten (1)
Star Strider
am 12 Apr. 2019
I’m not certain what you’re asking.
Try this:
format long g
q = str2num('110110111')
returns:
q =
110110111
1 Kommentar
Walter Roberson
am 12 Apr. 2019
Bearbeitet: Walter Roberson
am 12 Apr. 2019
However, if the first 1 is followed by 15 or more digits, then scientific notation will be used even though 16 digits is representable exactly as an integer.
You can get up to 20 digits exactly by using
sscanf('11111111111111111111', '%lu')
Beyond 20 decimal digits exceeds the capacity of uint64. Beyond that you need to use other tactics, such as
uint8(TheString - '0')
Siehe auch
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!