QB64.org Forum
Active Forums => QB64 Discussion => Topic started by: Dimster on October 16, 2018, 11:41:53 am
-
Is there a way to round scientific notation to whatever number of decimal places you want? Here is an example however it's cumbersome and uses String variables. If I could I would like to stay with pure numeric values/variables.
_FULLSCREEN
a = 52 / 3589
b = a * 100
c = INT(b)
d = b - c
e$ = STR$(d)
f$ = LEFT$(e$, 6)
f = VAL(f$)
g$ = RIGHT$(e$, 3)
PRINT
PRINT a
PRINT b
PRINT c
PRINT d
PRINT e$
PRINT f$
PRINT f
PRINT g$
IF VAL(g$) >= 500 THEN f = f + .0001
PRINT f
-
Check out Print Using: http://qb64.org/wiki/PRINT_USING
-
Isn't this just a case of:
Result = INT(number * 10 ^ digits) / 10 ^ digits
For 2 decimal places: X = INT(y * 100) / 100
For 3 decimal places: X = INT(y * 1000) / 1000
-
Thanks guys, I can use both solutions. I appreciate the help.