Nobody, thanks for the tip. It seems to work ok now. This also works:
Vector_sum = [word]Vr*Vr+[word]Vi*Vi.
I do not understand why this is necessary, as Vr and Vi will be a Byte variable. Can someone please explain why this is necessary. Thanks, Ed.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
GCBasic does not use word calculations, unless you specify it, or the inputs are words. The fact that is points to a word, does not trigger word math functions. This allows for more control on the operations and the savings of program code over assuming everything needs 16 bit math.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi all newbie here ran into another problem with the new release (0.9 12/8/2009)
I have a vector math problem:
Dim Vector_sum as word
Vr = 100
Vi = 49
Vector_sum = Vr*Vr+Vi*Vi, This does not work as Vector_sum = 113 not 12401
Vector_sum = Vr*Vr - Vi*Vi, This does not work as Vector_sum = 65455 not 7599
Vector_sum = Vr*Vr works Vector_sum = 10000
Vector_sum = Vr*Vr*2, This does not work as Vector_sum = 32 not 20000
The earlier release (0.9 24/1/2009) has the same problem
What is going on?
Regards, Ed.
I think you should declare Vr and Vi as word or force the operation to word.
Nobody, thanks for the tip. It seems to work ok now. This also works:
Vector_sum = [word]Vr*Vr+[word]Vi*Vi.
I do not understand why this is necessary, as Vr and Vi will be a Byte variable. Can someone please explain why this is necessary. Thanks, Ed.
GCBasic does not use word calculations, unless you specify it, or the inputs are words. The fact that is points to a word, does not trigger word math functions. This allows for more control on the operations and the savings of program code over assuming everything needs 16 bit math.