Effacer les filtres
Effacer les filtres

Dividing small number by a large number?

2 vues (au cours des 30 derniers jours)
Esteban
Esteban le 13 Juin 2012
Hi, I'm running a while loop within which I'm dividing integers (e.g 20, 40, 80) by 1e6 , but I keep getting '0' as my answer for each run of the while loop. What can I do to obtain as many values as possible to the right of the decimal point ? I've tried the 'format' method, but it doesn't seem to be working.
Any help is much appreciated.
Thanks!

Réponses (1)

Pavel Gorodetsky
Pavel Gorodetsky le 15 Juin 2012
by default, Matlab uses double to store numbers. if for some reason you are using int32 variables in your program, you could cast them to double:
double(a)/1e6
in case is of class int32. the format command only controls the way numbers are displayed in the command window. it does not effect the results

Catégories

En savoir plus sur Logical dans Help Center et File Exchange

Produits

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by