>from the help line-
>I\'ve got a superpro (1756), and your BASIC tools.
>I\'m new to both visual basic and microprocessors, so please be kind.
>How do I do floating point operations in BASIC with these tools?
>Say, just \"print 4/3.14159\" ??
----------------------------
In the help files
http://www.coridium.us/ARMhelp/scr/bExprEval.html
print 4/3.14 will result in 1 because the first operand in the expression is an integer, so integer evaluation is performed
print 4.0/3.14 will result in 1.273855 because the first operand is a floating point (SINGLE) number
brucee
expression evaluation
-
AMDlloydsp
- Posts: 99
- Joined: Mon Apr 15, 2013 3:51 pm
- Location: NE Central FL
Re: expression evaluation
Ok... tried that, and got the expected result, but when I tried it with variables instead of literals, no soap.
ie.
j=1.0
for i=1.0 to 20.0
print j/3.14159
next i
Thanks,
LS
ie.
j=1.0
for i=1.0 to 20.0
print j/3.14159
next i
Thanks,
LS
-
AMDlloydsp
- Posts: 99
- Joined: Mon Apr 15, 2013 3:51 pm
- Location: NE Central FL
Re: expression evaluation
duh... never mind.
I got it working once I declared the variables as SINGLEs
Thanks,
LS
I got it working once I declared the variables as SINGLEs
Thanks,
LS
Re: expression evaluation
You need to tell the compiler that j is a SINGLE (the default is INTEGER)
DIM j AS SINGLE ' will do it
-----------
PS - your first post has to be moderated, it keeps the spambots away (it is surprising how much time they waste trying to break into forums)
DIM j AS SINGLE ' will do it
-----------
PS - your first post has to be moderated, it keeps the spambots away (it is surprising how much time they waste trying to break into forums)
-
AMDlloydsp
- Posts: 99
- Joined: Mon Apr 15, 2013 3:51 pm
- Location: NE Central FL
Re: expression evaluation
Yes, thanks. I got past that.
From reading the docs (now), I presume that if I wish to use higher math functions like (say) trig [j=SIN(x)], that I must either write a fp routine to calculate it, drive it from a stored table, or must switch to the C compiler?
Are there some BASIC libraries with more math functions available?
Thanks,
LS
From reading the docs (now), I presume that if I wish to use higher math functions like (say) trig [j=SIN(x)], that I must either write a fp routine to calculate it, drive it from a stored table, or must switch to the C compiler?
Are there some BASIC libraries with more math functions available?
Thanks,
LS
Re: expression evaluation
There are a number of contributed and tested libraries in BASIC
They are installed in /program files (x86)/Coridium/BASIClib/Contributed/Float/AB_Math.lib
You can either cut and paste what you need
or #include that file and use #defines to select portions
They are installed in /program files (x86)/Coridium/BASIClib/Contributed/Float/AB_Math.lib
You can either cut and paste what you need
or #include that file and use #defines to select portions
-
AMDlloydsp
- Posts: 99
- Joined: Mon Apr 15, 2013 3:51 pm
- Location: NE Central FL
Re: expression evaluation
Thanks much!
I shall now take a test-flight!
LS
I shall now take a test-flight!
LS
-
AMDlloydsp
- Posts: 99
- Joined: Mon Apr 15, 2013 3:51 pm
- Location: NE Central FL
Re: expression evaluation
Nice. I didn't crash the plane.
I must say, this is a pretty easy environment to work in. I not what you'd call a 'programmer' (at all, I'm an explosives consultant)
but the math routines just 'fell into place' with only the tiniest bit of head-scratching.
'Good stuff. I think I'm hooked!
LS
I must say, this is a pretty easy environment to work in. I not what you'd call a 'programmer' (at all, I'm an explosives consultant)
but the math routines just 'fell into place' with only the tiniest bit of head-scratching.
'Good stuff. I think I'm hooked!
LS