Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Operator question.
#1
The calculation is strange....

QM Program
double b =4/10
out "%1.1f" b

output
0

but Calculator is 0.4

I want to know why calculation information is different.


Attached Files Image(s)
   
#2
Because 4 and 10 are int, the result is also int. At least one of them must be double.

Macro Macro2732
Code:
Copy      Help
out

double b
b=4/10; out b ;;0
b=4/10.0; out b ;;0.4
b=10/4; out b ;;2
b=10.0/4; out b ;;2.5

int c(4) d(10)
b=c/d; out b ;;0
b=1.0*c/d; out b ;;0.4
#3
Thank you very much.
I understand. Big Grin


Forum Jump:


Users browsing this thread: 1 Guest(s)