Download the free trial version
Basic4android Video
Features
Tutorials and manuals
Showcase
Screenshots

Go Back   Android Development Forum - Basic4android > Basic4ppc (Windows Mobile) > Code Samples & Tips
Documentation Wiki Register Members List B4P Search Today's Posts Mark Forums Read

Code Samples & Tips Share your recent discoveries and ideas with other users.

Scientific Math Text Input Evaluator

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 11-21-2007, 07:02 AM
Senior Member
 
Join Date: May 2007
Posts: 174
Awards Showcase
Beta Tester 
Total Awards: 1
Default Scientific Math Text Input Evaluator

Hi

Attached is code to evaluate math same as Basic4ppc code operations.

This supports ^, MOD, /,*,-,+, INT,ABS,SIN,COS,TAN,ASIN,ACOS, ATAN,LN,LOG,EX(for e),E[E+,E-](for eng'g),PI,SQRT,Factorial(!)integer up to 170(max).

calculations in radians.

I've tried to compare results to Basic4PPC operations and it's ok, but still need to test for other bugs.(sometimes I got last (13th)decimal place descripancy in comparison).

EDIT: file updated by Rioven 26JAN09-fixed bugs on ^ function, added input error filters on parenthesis.
EDIT: file updated by Rioven 24JAN09 -fixed bug
EDIT: file updated by Klaus 21JAN09 -added LOG & SQRT functions

Regards,
Attached Files
File Type: sbp MathCode02_2_3.sbp (12.5 KB, 121 views)
__________________
Rioven

DEVICE: Motorola ATRIX (Dual Core) Android 2.2.1
DESKTOP: Intel Pentium Dual-core E5200; Microsoft® Windows® Vista Home (Basic); Hard Disk:320GB; Memory:4096MB

Last edited by Rioven : 01-26-2009 at 03:18 PM. Reason: Uploaded the updated file by Rioven
Reply With Quote
  #2 (permalink)  
Old 11-22-2007, 02:23 AM
Senior Member
 
Join Date: May 2007
Posts: 174
Awards Showcase
Beta Tester 
Total Awards: 1
Default Factorial function added

Now also supports factorial 170! maximum. (integer number only)

Fixed, Entering constant(PI or EX) alone now returns value.

TIP: New Variables/constants can be added at line 380.
Attached Images
File Type: jpg MathCode02.JPG (75.4 KB, 125 views)
__________________
Rioven

DEVICE: Motorola ATRIX (Dual Core) Android 2.2.1
DESKTOP: Intel Pentium Dual-core E5200; Microsoft® Windows® Vista Home (Basic); Hard Disk:320GB; Memory:4096MB

Last edited by Rioven : 12-06-2007 at 10:01 AM. Reason: file removed, updated available
Reply With Quote
  #3 (permalink)  
Old 11-22-2007, 03:53 AM
Junior Member
 
Join Date: Apr 2007
Location: Kerikeri, New Zealand
Posts: 43
Send a message via MSN to HarleyM
Thumbs up Just the ticket!!

Nice work !!! I have a partially written project to graph a range of numbers based on a formula in a text box. Bingo !! you have the missing link I was looking for.
Reply With Quote
  #4 (permalink)  
Old 11-22-2007, 05:53 AM
Senior Member
 
Join Date: May 2007
Posts: 174
Awards Showcase
Beta Tester 
Total Awards: 1
Default

Hi HarleyM,

This from my old code just converted to Basic4ppc, It can be optimized further. I created this function for my project that user can alter the default calculation formula or input their own formula.

Hope it works well for you.
Please test it more and let me know if there are still problems.

Regards,
Rioven
__________________
Rioven

DEVICE: Motorola ATRIX (Dual Core) Android 2.2.1
DESKTOP: Intel Pentium Dual-core E5200; Microsoft® Windows® Vista Home (Basic); Hard Disk:320GB; Memory:4096MB
Reply With Quote
  #5 (permalink)  
Old 11-23-2007, 12:16 PM
Junior Member
 
Join Date: Apr 2007
Location: Kerikeri, New Zealand
Posts: 43
Send a message via MSN to HarleyM
Default Hi Rioven

I connected your code into a program that I'd written around Erel's Eval routine. Your code breathes new life into it. Allowing the user to select a range of x values & uses your routines to populate a table based on the formula entered into a text box. The user can then display the table in one of 3 graph formats. Thanks again for the work you did in creating the expression calculator. I only needed to change one thing & that was to reset the 'C' variable after a calculation so that it would accept modified variables thereafter.

Cheers!!
Reply With Quote
  #6 (permalink)  
Old 11-24-2007, 06:53 AM
Senior Member
 
Join Date: May 2007
Posts: 174
Awards Showcase
Beta Tester 
Total Awards: 1
Default

Quote:
Originally Posted by HarleyM View Post
I connected your code into a program that I'd written around Erel's Eval routine. Your code breathes new life into it. Allowing the user to select a range of x values & uses your routines to populate a table based on the formula entered into a text box. The user can then display the table in one of 3 graph formats. Thanks again for the work you did in creating the expression calculator. I only needed to change one thing & that was to reset the 'C' variable after a calculation so that it would accept modified variables thereafter.

Cheers!!
Hi HarleyM,
Thanks for pointing out the C variable to reset.
I attached the revised code and this is still
I've fixed some input variable/constant filters and bug on dividing negative value.
The code requires more input filters or errorhandling and tests.

Regards,
Attached Files
File Type: sbp MathCode02.1.sbp (12.4 KB, 116 views)
__________________
Rioven

DEVICE: Motorola ATRIX (Dual Core) Android 2.2.1
DESKTOP: Intel Pentium Dual-core E5200; Microsoft® Windows® Vista Home (Basic); Hard Disk:320GB; Memory:4096MB

Last edited by Rioven : 11-24-2007 at 06:55 AM.
Reply With Quote
  #7 (permalink)  
Old 01-20-2009, 06:44 PM
Filippo's Avatar
Basic4ppc Expert
 
Join Date: May 2007
Location: Schwäb. Gmünd, Germany
Posts: 977
Awards Showcase
Beta Tester 
Total Awards: 1
Default

Hallo Rioven,

your Function "COMPUTER(FORMULAs)" is very good!
I use it in my B4P-Calculator. What I still miss is the SQRT-function.


Ciao,
Filippo
__________________
PPC: MDA Pro, 2GB SD
Device: HTC Desire , Android 2.2
______________________
Reply With Quote
  #8 (permalink)  
Old 01-20-2009, 08:33 PM
klaus's Avatar
Basic4ppc Expert
 
Join Date: Oct 2007
Location: Fully, Switzerland
Posts: 4,463
Awards Showcase
Forum Contributer Beta Tester Competition Winner 
Total Awards: 3
Default

Hallo Filippo,

Here you are, added SQRT and LOG.
There are some strange behaviours, also in version 2.1, I haven't yet looked in detail on what happens.

Best regards.

EDIT: Removed the program, it has been updated by Rioven in the original post.
__________________
Klaus
Switzerland

Beginner's Guide / User's Guide

Last edited by klaus : 01-22-2009 at 07:47 AM.
Reply With Quote
  #9 (permalink)  
Old 01-21-2009, 07:05 AM
Filippo's Avatar
Basic4ppc Expert
 
Join Date: May 2007
Location: Schwäb. Gmünd, Germany
Posts: 977
Awards Showcase
Beta Tester 
Total Awards: 1
Default

Hallo Klaus,

thank you very much.
__________________
PPC: MDA Pro, 2GB SD
Device: HTC Desire , Android 2.2
______________________
Reply With Quote
  #10 (permalink)  
Old 01-22-2009, 05:28 AM
Senior Member
 
Join Date: May 2007
Posts: 174
Awards Showcase
Beta Tester 
Total Awards: 1
Default

Quote:
Originally Posted by klaus View Post
Hallo Filippo,

Here you are, added SQRT and LOG.
There are some strange behaviours, also in version 2.1, I haven't yet looked in detail on what happens.

Best regards.
Hello Klaus,
Thanks for the added functions.
I hope you could have some times to have a look on these strange behaviours.

Hello Filippo,
If there are other functions that still need to add, It can be simply added under line 272 'special operators', just follow the pattern.

Any additional Constant can also be simply added under line 390 & 403 and also define under 'Sub Globals'.

Note: the latest file 'Mathcode02_2.sbp' updated by Klaus also been uploaded on the first post of this thread.

Thanks & regards,
Rioven
__________________
Rioven

DEVICE: Motorola ATRIX (Dual Core) Android 2.2.1
DESKTOP: Intel Pentium Dual-core E5200; Microsoft® Windows® Vista Home (Basic); Hard Disk:320GB; Memory:4096MB

Last edited by Rioven : 01-22-2009 at 06:35 AM. Reason: added message...
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Small math-trainer token Share Your Creations 3 07-17-2008 06:29 PM
Fixed Point Math im4retro Questions (Windows Mobile) 3 05-31-2008 06:13 AM
Help with Math function go4saint Questions (Windows Mobile) 2 03-31-2008 09:15 AM
RPNCalc a simple scientific calculator klaus Share Your Creations 1 11-13-2007 12:26 PM
ComboBox text input mwaite Questions (Windows Mobile) 1 06-07-2007 07:04 PM


All times are GMT. The time now is 09:33 PM.


Powered by vBulletin® Version 3.6.12
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0