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
  #21 (permalink)  
Old 01-26-2009, 07:57 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

Hello Rioven,

Thank you!
I have your module installed in my update.


Ciao,
Filippo
__________________
PPC: MDA Pro, 2GB SD
Device: HTC Desire , Android 2.2
______________________
Reply With Quote
  #22 (permalink)  
Old 01-29-2009, 03:45 PM
agraham's Avatar
Basic4ppc Expert
 
Join Date: Jul 2007
Location: Cheshire, UK
Posts: 6,072
Awards Showcase
Innovator medal Beta Tester Forum Contributer 
Total Awards: 3
Default

Quote:
Originally Posted by klaus View Post
-2^2 = -4 that's normal and must be so !
I hate to disagree but not necessarily so. Look at note one under "References and Notes" in that Wikipedia article you linked to. Also in the table of precedence for C type programs under "Mathematical precedence" the unary operators have the second highest precedence though you can't apply this example as C does not implement an exponentiation operator (it uses a function instead). My own opinion is that the "obvious" place for "^" is above the " * / % " operators and below unary " + - ".

In a Recursive Descent Parser, like the one I wrote for my BasicLib library, the "natural" place to put the unary operators is at the highest precedence so thay are treated like Sin(..) and Rnd(..) etc. In this case the unary " - " is like a Neg(...) function.

-2^2 = (-2)^2 = Neg(2)^2 = 4

Regardless of that, for many many years have I have not relied on precedence but always use parentheses in any but the simplest expression to make the order of evaluation explicit and most importantly, obvious.
Reply With Quote
  #23 (permalink)  
Old 01-30-2009, 11:30 AM
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

Hi Andrew,

For the -2^2 = -4
I was reasoning like written or printed mathematics and not in programming language and for me the ^ sign is the exponant operator.

And it's the same reasoning as when -2^2 is somewhere else in the equation like:
5-2^2 = 1

Besides in B4PPC and VB -2^2= -4

Best regards.
__________________
Klaus
Switzerland

Beginner's Guide / User's Guide
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:32 PM.


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