Shop OBEX P1 Docs P2 Docs Learn Events
Adding Decimals with BS2!! — Parallax Forums

Adding Decimals with BS2!!

bomberbomber Posts: 297
edited 2011-06-14 16:27 in BASIC Stamp
As most of you know, using decimals in regular math computation is almost an imposibility. I have contrived some code to add two decimal numbers together. There are some notes that are in the code. Please read the notes at the beginning of the program. They tell you how to use the program. There are a few bugs that will give you an INCORRECT ANWSER unless you follow the directions at the beginning of the code.


UPDATE!!! The constant "dec_digits" defines the number of digits in the decimal place. if the constant "dec_digits" is smaller then the actual number of digits, It will be incorrect. if dec_digits = 2 and the entered number is 1 digit long, it will read incorrectly! you MUST put it in the form of ".10" if dec_digits = 2.

Comments

  • ercoerco Posts: 20,256
    edited 2011-06-13 17:03
    Looks good, Bomber. I'll check it out at home. Integer math takes some getting used to, huh? :)
  • bomberbomber Posts: 297
    edited 2011-06-13 18:10
    UPDATE!!! The constant "dec_digits" defines the number of digits in the decimal place. if the constant "dec_digits" is smaller then the actual number of digits, It will be incorrect. if dec_digits = 2 and the entered number is 1 digit long, it will read incorrectly! you MUST put it in the form of ".10" if dec_digits = 2.
  • vaclav_salvaclav_sal Posts: 451
    edited 2011-06-14 16:27
    Right church – wrong pew.
    Nice article, however, I would suggest in the future to do some research as far as terminology used.
    “Decimals” and floating point arithmetic performed are not identical.
    Cheers
    Vaclav
Sign In or Register to comment.