Author Topic: a super simple eval  (Read 5909 times)

0 Members and 1 Guest are viewing this topic.

Offline jack

  • Seasoned Forum Regular
  • Posts: 408
    • View Profile
Re: a super simple eval
« Reply #15 on: June 21, 2020, 05:30:52 pm »
do have a link to your string math routines?

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: a super simple eval
« Reply #16 on: June 21, 2020, 05:33:41 pm »
I think it's here: https://www.qb64.org/forum/index.php?topic=1093.0

Warning it's not simple.

Offline jack

  • Seasoned Forum Regular
  • Posts: 408
    • View Profile
Re: a super simple eval
« Reply #17 on: June 21, 2020, 06:33:58 pm »
I tried to compile BNC from http://www.rain.org/~mkummel/tbvault.html
but there are too many duplicated symbols and a ton of string concatenations using & which QB64 doesn't like, so I gave up

Offline Pete

  • Forum Resident
  • Posts: 2361
  • Cuz I sez so, varmint!
    • View Profile
Re: a super simple eval
« Reply #18 on: June 21, 2020, 08:20:13 pm »
https://www.tapatalk.com/groups/qbasic/viewtopic.php?p=212679#p212679

The second one of the two on that page is the most updated one I have. It matches the last build in my QB64 database.

It would need a lot more additions to use as a calculator, log functions, exponents, square roots, etc. This was something it looks like I did a year ago, for fun. Since I have no practical use for it, I moved on to other things, as just what was mentioned above would have nearly doubled the program size.

Computers suck at math, which is just so ironic, but obviously programmers found ways around this base two challenge to produce working calculator apps.

Since I just decided to manipulate numbers as strings, I never explored any other possible non-string converting methods, although I did work a bit with large data types like _INTEGER64 and _FLOAT, but eventually they break, too.

Pete
Want to learn how to write code on cave walls? https://www.tapatalk.com/groups/qbasic/qbasic-f1/

Offline jack

  • Seasoned Forum Regular
  • Posts: 408
    • View Profile
Re: a super simple eval
« Reply #19 on: June 21, 2020, 08:48:31 pm »
thanks Pete
BTW, I changed the float type to _float, so now your example 5 - 5.1 = .1 :)
it was a fun distraction building and debugging this evaluator

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: a super simple eval
« Reply #20 on: June 21, 2020, 09:39:24 pm »
thanks Pete
BTW, I changed the float type to _float, so now your example 5 - 5.1 = .1 :)
it was a fun distraction building and debugging this evaluator

new math?

Offline Pete

  • Forum Resident
  • Posts: 2361
  • Cuz I sez so, varmint!
    • View Profile
Re: a super simple eval
« Reply #21 on: June 21, 2020, 10:02:08 pm »
thanks Pete
BTW, I changed the float type to _float, so now your example 5 - 5.1 = .1 :)
it was a fun distraction building and debugging this evaluator

Yep, now all you have to do is calculate the limitations, if you want to make it into a working calculator. I remember the old TI ones, from the early 1980's. They just throw a E on the screen for error, at some point. 16 digit display for the better ones, 8 digit display for the less expensive ones.

Pete
Want to learn how to write code on cave walls? https://www.tapatalk.com/groups/qbasic/qbasic-f1/

Offline jack

  • Seasoned Forum Regular
  • Posts: 408
    • View Profile
Re: a super simple eval
« Reply #22 on: June 22, 2020, 05:33:22 am »
new math?
in my haste I forgot the - sign in the post.

Offline Unseen Machine

  • Forum Regular
  • Posts: 158
  • Make the game not the engine!
    • View Profile
Re: a super simple eval
« Reply #23 on: June 22, 2020, 05:39:27 am »
Quick and dirty trig functions you say!?

Quote
SUB GDK_MathX
  DECLARE LIBRARY
    FUNCTION atan2# (BYVAL y#, BYVAL x#)
    FUNCTION acos# (BYVAL x#)
    FUNCTION asin# (BYVAL x#)
    FUNCTION cosh# (BYVAL x#)
    FUNCTION sinh# (BYVAL x#)
    FUNCTION tanh# (BYVAL x#)
    FUNCTION pow# (BYVAL base#, BYVAL exponent#)
  END DECLARE
END SUB

Hope it helps

Unseen