Shop OBEX P1 Docs P2 Docs Learn Events
Newbie currency question — Parallax Forums

Newbie currency question

ArchiverArchiver Posts: 46,084
edited 2003-12-16 19:25 in General Discussion
Is there a way to display the following equation as currency without
the use of a math co-processor?

SEROUT 14,N9600,[noparse][[/noparse]"$ ",DEC COUNT*100/500," TOTAL NOW"]
ETC........

Please realize that the equation was really COUNT*.05 but since the
stamp does not accept decimals I upscaled the equation to integer
levels. My problem is that the the variable COUNT is a minute counter
for a machine. The machine may run for more that 655 minutes at a time
which will certainly push the result over 65535. I'm sure this
question has been asked in the past and I am sorry I had to bring it
up again..Thanks for the help.

Comments

  • ArchiverArchiver Posts: 46,084
    edited 2003-12-16 16:54
    Sometimes fractions work conveniently and we can do a simple divide. In
    you example, multiplying by 0.05 is the same as dividing by 20. I'm not
    smart enough to know this off the top of my head. Whenever I have a
    fraction, I enter it into my calculator and then press the reciprocal
    button [noparse][[/noparse]1/x]. If the value is a whole number, or very close to it, I
    will divide by that number.

    So you can do this:

    SEROUT, 14, N9600, [noparse][[/noparse]"$", DEC count/20, ....]

    When a fractional value doesn't work out to be an even divisor, there is
    always the */ and ** operators which allow us to multiply by fractional
    values.

    -- Jon Williams
    -- Applications Engineer, Parallax
    -- Dallas Office



    Original Message
    From: generatorlabs [noparse]/noparse]mailto:[url=http://forums.parallaxinc.com/group/basicstamps/post?postID=5r-fRbCLxrsYoGVfVBXn-yQMJ5BT3IK59Y4KvutNFEHR83UQfFuppjQfeqGBrs9vIPn5tdbjU6V82w28PA]generatorlabs@y...[/url
    Sent: Tuesday, December 16, 2003 12:07 AM
    To: basicstamps@yahoogroups.com
    Subject: [noparse][[/noparse]basicstamps] Newbie currency question


    Is there a way to display the following equation as currency without the
    use of a math co-processor?

    SEROUT 14,N9600,[noparse][[/noparse]"$ ",DEC COUNT*100/500," TOTAL NOW"] ETC........

    Please realize that the equation was really COUNT*.05 but since the
    stamp does not accept decimals I upscaled the equation to integer
    levels. My problem is that the the variable COUNT is a minute counter
    for a machine. The machine may run for more that 655 minutes at a time
    which will certainly push the result over 65535. I'm sure this question
    has been asked in the past and I am sorry I had to bring it up
    again..Thanks for the help.




    To UNSUBSCRIBE, just send mail to:
    basicstamps-unsubscribe@yahoogroups.com
    from the same email address that you subscribed. Text in the Subject
    and Body of the message will be ignored.


    Yahoo! Groups Links

    To visit your group on the web, go to:
    http://groups.yahoo.com/group/basicstamps/

    To unsubscribe from this group, send an email to:
    basicstamps-unsubscribe@yahoogroups.com

    Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/




    This message has been scanned by WebShield. Please report SPAM to
    abuse@p....
  • ArchiverArchiver Posts: 46,084
    edited 2003-12-16 19:25
    Hi,

    You charge a flat nickel per count, so at the ticks=65535, the charge
    will be $3276.75. So output like this:

    SEROUT 14,N9600,[noparse][[/noparse]"$",DEC ticks/20.".",ticks//20*5," TOTAL NOW"]

    For example, break it down, ticks=65535 becomes
    65535*5 = 3276*100 + 75 cents = $3276.75

    ticks/20 = 3276 dropping the remainder
    ticks//20 = 15 the remainder, ticks=3276*20+15
    ticks//20*5=75

    Be careful about using COUNT as a variable. It is a reserved word.

    -- Tracy
    http://www.emesystems.com/BS2index.htm



    >Is there a way to display the following equation as currency without
    >the use of a math co-processor?
    >
    >SEROUT 14,N9600,[noparse][[/noparse]"$ ",DEC COUNT*100/500," TOTAL NOW"]
    >ETC........
    >
    >Please realize that the equation was really COUNT*.05 but since the
    >stamp does not accept decimals I upscaled the equation to integer
    >levels. My problem is that the the variable COUNT is a minute counter
    >for a machine. The machine may run for more that 655 minutes at a time
    >which will certainly push the result over 65535. I'm sure this
    >question has been asked in the past and I am sorry I had to bring it
    >up again..Thanks for the help.
    >
    >
Sign In or Register to comment.