Problem with IntQ
Posted: Sun Mar 30, 2008 12:21 am
Can anyone explain the following?
---------------------------
OpenConsole()
tmp.d = 195.0344317566
PrintN (StrD (tmp.d) )
---------------------------
; will print: "195.0344317566" which is correct
; but if I now want the integer part and the decimal part in two separate
; variables I try with...
;
whole.i = IntQ (tmp.d)
PrintN (StrD (whole.i) )
;
; which doesn't work, for some reason I cannot add .i only .q. Why do I have to write whole.q as quad?
; And once forced to change the code to...
;
whole.q = IntQ (tmp.d) ; as I want the integer part of the number
PrintN (StrD (whole.q) )
;
; I get the result "195.0000000000" instead of simply "195" which I want
;
; And finally trying to get the decimal part of the number I write...
;
rest.d = (tmp.d - whole.q)
PrintN (StrD (rest.d) )
;
; which prints "0.0000000000" instead of "0.0344317566"
;
Input()
CloseConsole()
----------------
It doesn't make sense!
Can anyone explain this?
Finally, is there any equivalent command for the C-style of formatted printing, like...
printf("%10s\t%11.7f\t%10.7\t%10.4f\t%10.2f\n", snam, x[0],x[1],x[2],x[3]); ?
---------------------------
OpenConsole()
tmp.d = 195.0344317566
PrintN (StrD (tmp.d) )
---------------------------
; will print: "195.0344317566" which is correct
; but if I now want the integer part and the decimal part in two separate
; variables I try with...
;
whole.i = IntQ (tmp.d)
PrintN (StrD (whole.i) )
;
; which doesn't work, for some reason I cannot add .i only .q. Why do I have to write whole.q as quad?
; And once forced to change the code to...
;
whole.q = IntQ (tmp.d) ; as I want the integer part of the number
PrintN (StrD (whole.q) )
;
; I get the result "195.0000000000" instead of simply "195" which I want
;
; And finally trying to get the decimal part of the number I write...
;
rest.d = (tmp.d - whole.q)
PrintN (StrD (rest.d) )
;
; which prints "0.0000000000" instead of "0.0344317566"
;
Input()
CloseConsole()
----------------
It doesn't make sense!
Can anyone explain this?
Finally, is there any equivalent command for the C-style of formatted printing, like...
printf("%10s\t%11.7f\t%10.7\t%10.4f\t%10.2f\n", snam, x[0],x[1],x[2],x[3]); ?