• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Identifying Unary minus in calculator, java

 
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi guys i'm almost done writing my code and i'm stuck with this stupid thing. I can identify cases in which there's a unary minus before brackets (-[4 + 4]). here's my code:



it long i know. Expression object could be a constant, a variable or a function such as MAX{3,2} which is 3. expression() uses a tokenizer i have built to parse text into an expression, and sumExpression() uses expression() to create a new Expression which is a combination of two Expression object according to the right operator.

i hope its clear. as i said before i can't figure out how to identify the unary minus (-[4] would be -4) thing. i didn't put my tokenizer code, didn't think its necessary.

thanks!

P.S. the order of calculations is defined to be left to right with no regards to type of operator.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic