I have converted the string 04567 to double by using str2double function.But I got the output as 4567.But I need the output as 04567 .How can it be done?
古いコメントを表示
I have converted the string 04567 to double by using str2double function.But I got the output as 4567.But I need the output as 04567 .How can it be done?
回答 (1 件)
bio lim
2015 年 7 月 11 日
0 投票
As a string, obviously you can have a leading zero. However, as you convert it to double or number, the leading numeral 0 is lost, because the numbers you converted, 4567 cannot start with 0.
4 件のコメント
Anushka
2015 年 7 月 11 日
bio lim
2015 年 7 月 11 日
I think the only way is to keep it as a string. Why do you want leading zero in the first place? Can you provide the full context?
Anushka
2015 年 7 月 11 日
編集済み: Walter Roberson
2015 年 7 月 11 日
What exactly do you want "the binary representation" of:
- the string of characters '04567'
- the double 4567
- the vector of digits [0,4,5,6,7]
- something else?
In a sense all numbers have implicit leading and trailing zeros, even if these are not displayed in normal representations. But you really need to tell us what data "the correct binary representation" should be representing.
カテゴリ
ヘルプ センター および File Exchange で Data Type Conversion についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!