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]); ?
Problem with IntQ
Try this
Couple of fundamental errors in there. 
Code: Select all
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 = Int (tmp.d)
PrintN (Str (whole) )
;
; 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 = Int(tmp.d) ; as I want the integer part of the number
PrintN (Str (whole) )
;
; 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)
PrintN (StrD (rest) )
;
; which prints "0.0000000000" instead of "0.0344317566"
;
Input()
CloseConsole()
Because .i isn't a type. It's .l for Long.whole.i = IntQ (tmp.d)
; which doesn't work, for some reason I cannot add .i only .q. Why do I have to write whole.q as quad?
Also, there's not reason to use IntQ() if you put the result in a long. Then you can just the normal Int().
StrD() is for Doubles. StrQ() is for quads.PrintN (StrD (whole.q) )
;
; I get the result "195.0000000000" instead of simply "195" which I want
Here it prints 0.034...rest.d = (tmp.d - whole.q)
PrintN (StrD (rest.d) )
;
; which prints "0.0000000000" instead of "0.0344317566"
Code: Select all
Global Tmp.d
Global Whole.q
Global Rest.d
OpenConsole()
tmp = 195.0344317566
PrintN(StrD(tmp))
whole = IntQ(tmp)
PrintN(StrQ(whole))
rest = (tmp - whole)
PrintN (StrD (rest) )
Input()
CloseConsole()


