division of float numbers
11 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Hi, MATLAB is usually showed the result of float number with four digits, how we can get only two digits after the decimal point. Ex: a = 532.7589 I want to get it as a=532.76 and please I DONOT want to use fprintf('%.2f', a) Thanks in advance
0 Kommentare
Antworten (1)
Star Strider
am 29 Okt. 2017
9 Kommentare
Star Strider
am 29 Okt. 2017
If you want what you describe, you have to use the round function in addition to format short g:
format shortg
x = [4.548934 89.0009];
x = round(x,2)
x =
4.55 89
You have to live with the constraints of the software you use.
Walter Roberson
am 30 Okt. 2017
Now, 34.00000000000000710542735760100185871124267578125 is not an integer, but it rounds to an integer -- it is the very next representable number after 34 exactly. Should 34.00000000000000710542735760100185871124267578125 be displayed as 34 or as 34.00 ?
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!