expression evaluation

Questions about the BASICtools and MakeItC
Post Reply
basicchip
Posts: 1090
Joined: Fri Oct 19, 2012 2:39 am
Location: Weeki Watchee, FL
Contact:

expression evaluation

Post by basicchip »

>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



AMDlloydsp
Posts: 99
Joined: Mon Apr 15, 2013 3:51 pm
Location: NE Central FL

Re: expression evaluation

Post by AMDlloydsp »

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

AMDlloydsp
Posts: 99
Joined: Mon Apr 15, 2013 3:51 pm
Location: NE Central FL

Re: expression evaluation

Post by AMDlloydsp »

duh... never mind.

I got it working once I declared the variables as SINGLEs

Thanks,
LS

basicchip
Posts: 1090
Joined: Fri Oct 19, 2012 2:39 am
Location: Weeki Watchee, FL
Contact:

Re: expression evaluation

Post by basicchip »

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)

AMDlloydsp
Posts: 99
Joined: Mon Apr 15, 2013 3:51 pm
Location: NE Central FL

Re: expression evaluation

Post by AMDlloydsp »

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

basicchip
Posts: 1090
Joined: Fri Oct 19, 2012 2:39 am
Location: Weeki Watchee, FL
Contact:

Re: expression evaluation

Post by basicchip »

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

AMDlloydsp
Posts: 99
Joined: Mon Apr 15, 2013 3:51 pm
Location: NE Central FL

Re: expression evaluation

Post by AMDlloydsp »

Thanks much!
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

Post by AMDlloydsp »

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

Post Reply