eh?
LOCAL alpha#=1
FOR rim=0 TO 5
DEBUG "\n"+alpha
alpha#=alpha#-0.3
NEXT
I am getting 1.e-001 when it should be returning 0.1,This is no good as i am feeding the numbers into alpha,What am i doing wrong?
i have added the line IF alpha# >0 AND alpha#< 0.1 THEN alpha=0.1
so the code works,just seems strange.
Have you tried formatting the number? Such as (4 characters wide, 2 decimals):
DEBUG "\n" + FORMAT$(4, 2, alpha#)
Thanks for the reply but i need to put the number into an array so unless i convert the string back to a number this won't work.
GLOBAL alph[]
DIM alph[7]
LOCAL w=0
DEBUG "\n Formatted string"
FOR q#=-1 TO 1 STEP 0.3
DEBUG "\n" + FORMAT$(4, 2, q#)
alph[w]=q
INC w
NEXT
DEBUG "\n next one"
FOR p=0 TO BOUNDS(alph[],0)-1
DEBUG "\n"+alph[p]
NEXT
I'm not too clear what you are saying.
The number is always a correct, valid number, even though sometimes it displays in scientific notation (without formatting).
You only need to use the FORMAT command when you want to display the value, not when storing it into the array.
Right,just me being stupid.I assumed it would mess the alphamode settings up.
Thanks.
This is not a bug, but this is how floating point works in the cpu.
The only workaround is just multiply it with 100, so you get a INTEGER value between 0 and 100. When alpha is used, just divided it with 100.
Thanks SF
DEBUG will display numbers in scientific format - so for easily read numbers you need to format it. STDOUT probably does the same too. PRINT certainly does.