Calculate the sum of all values in the stack - Hewlett Packard

This is a discussion on Calculate the sum of all values in the stack - Hewlett Packard ; Hi to all, I'd like to know if there's some trick to calculate the sum of all the existing values of the stack so I can avoid the use of the plus key all the time (sometimes I need to ...

+ Reply to Thread
Results 1 to 13 of 13

Thread: Calculate the sum of all values in the stack

  1. Calculate the sum of all values in the stack

    Hi to all,

    I'd like to know if there's some trick to calculate the sum of all the
    existing values of the stack so I can avoid the use of the plus key
    all the time (sometimes I need to calculate the sum of twenty or more
    values - integers most of the time - ). Do I need to write a program
    to do that? If that were de case, would you mind to write it down for
    me?

    Really, thank you very much,

    Francesc

  2. Re: Calculate the sum of all values in the stack

    Hi,

    DEPTH ->LIST
    DUP LIST->
    1 SWAP
    START
    +
    NEXT


    HTH

    Raymond


    "franfar" schrieb im Newsbeitrag
    news:86ce8c0e-9ada-4c0d-b70b-8a2e79c92d47@k30g2000hse.googlegroups.com...
    > Hi to all,
    >
    > I'd like to know if there's some trick to calculate the sum of all the
    > existing values of the stack so I can avoid the use of the plus key
    > all the time (sometimes I need to calculate the sum of twenty or more
    > values - integers most of the time - ). Do I need to write a program
    > to do that? If that were de case, would you mind to write it down for
    > me?
    >
    > Really, thank you very much,
    >
    > Francesc




  3. Re: Calculate the sum of all values in the stack - THANKS

    Thank you very much Raimond

    Best regards,

    Francesc

  4. Re: Calculate the sum of all values in the stack

    On Jun 25, 6:08 pm, "Raymond Del Tondo" wrote:
    > Hi,
    >
    > DEPTH ->LIST
    > DUP LIST->
    > 1 SWAP
    > START
    > +
    > NEXT
    >
    > HTH
    >
    > Raymond
    >
    > "franfar" schrieb im Newsbeitragnews:86ce8c0e-9ada-4c0d-b70b-8a2e79c92d47@k30g2000hse.googlegroups.com...
    >
    > > Hi to all,

    >
    > > I'd like to know if there's some trick to calculate the sum of all the
    > > existing values of the stack so I can avoid the use of the plus key
    > > all the time (sometimes I need to calculate the sum of twenty or more
    > > values - integers most of the time - ). Do I need to write a program
    > > to do that? If that were de case, would you mind to write it down for
    > > me?

    >
    > > Really, thank you very much,

    >
    > > Francesc


    Raymond, you are joking aren't you, what about <LIST
    sigmaLIST ???
    cheers,
    reth

  5. Re: Calculate the sum of all values in the stack


    > Raymond, you are joking aren't you, what about <LIST
    > sigmaLIST ???
    > cheers,
    > reth


    I like that !

    Can you have some other statistics in the same way ? (Average,
    variance, sum of squares, etc )

    Can stack be a sigmaDATA set to do it ?.

    Thanks.

    Daniel

  6. Re: Calculate the sum of all values in the stack

    "reth" schrieb im Newsbeitrag
    news:674e2e8b-280d-4212-a30d-3d617268f1f1@s21g2000prm.googlegroups.com...
    > On Jun 25, 6:08 pm, "Raymond Del Tondo" wrote:
    > [..]
    > Raymond, you are joking aren't you, what about <LIST
    > sigmaLIST ???
    > cheers,
    > reth
    >

    Hi reth,

    yes, that's more elegant, of course.

    Actually I never used sigmaLIST, so I didn't have that in mind;-)

    However to get the same result as my discrete code,
    with the stack contents retained,
    it would look like this UserRPL snippet:
    DEPTH ->LIST DUP LIST-> 1 + ROLL sigmaLIST

    Not very memory-efficient, as most of the list manipulation functions.

    In SysRPL, this could have been solved by the following snippet:
    DEPTH {}N DUP >R INNERCOMP DROP R> 'EvalNoCK: sigmaLIST


    Cheers

    Raymond



  7. Re: Calculate the sum of all values in the stack

    In article ,
    "Raymond Del Tondo" wrote:

    > Hi,
    >
    > DEPTH ->LIST
    > DUP LIST->
    > 1 SWAP
    > START
    > +
    > NEXT


    Better is

    \<< DEPTH \->LIST 0 + \GSLIST \>>

    where \<<, and \>> are the program delimiters,
    \-> is the right arrow symbol and
    \GS is the upper case Greek 's', or sigma, symbol.

    The only purpose of the " 0 + " is to allow you to use the program on an
    empty stack without getting an error message. And that sum will , of
    course, be 0.

    >
    >
    > "franfar" schrieb im Newsbeitrag
    > news:86ce8c0e-9ada-4c0d-b70b-8a2e79c92d47@k30g2000hse.googlegroups.com...
    > > Hi to all,
    > >
    > > I'd like to know if there's some trick to calculate the sum of all the
    > > existing values of the stack so I can avoid the use of the plus key
    > > all the time (sometimes I need to calculate the sum of twenty or more
    > > values - integers most of the time - ). Do I need to write a program
    > > to do that? If that were de case, would you mind to write it down for
    > > me?
    > >
    > > Really, thank you very much,
    > >
    > > Francesc


  8. Re: Calculate the sum of all values in the stack

    On Jun 25, 7:20*pm, "Raymond Del Tondo" wrote:
    > "reth" schrieb im Newsbeitragnews:674e2e8b-280d-4212-a30d-3d617268f1f1@s21g2000prm.googlegroups.com...> On Jun 25, 6:08 pm, "Raymond Del Tondo" wrote:
    > > [..]
    > > Raymond, you are joking aren't you, what about <LIST
    > > sigmaLIST ???
    > > cheers,
    > > reth

    >
    > Hi reth,
    >
    > yes, that's more elegant, of course.
    >
    > Actually I never used sigmaLIST, so I didn't have that in mind;-)
    >
    > However to get the same result as my discrete code,
    > with the stack contents retained,
    > it would look like this UserRPL snippet:
    > DEPTH ->LIST DUP LIST-> 1 + ROLL sigmaLIST
    >
    > Not very memory-efficient, as most of the list manipulation functions.
    >
    > In SysRPL, this could have been solved by the following snippet:
    > DEPTH {}N DUP >R INNERCOMP DROP R> 'EvalNoCK: sigmaLIST
    >
    > Cheers
    >
    > Raymond


    Question: What is the difference between UserRPL and SysRPL ???

    I did a search on the manual, and per the manual UserRPL is the
    program language enclosed by << >> ; I did a search on SysRPL (Find
    function) and nothing came up ??? There must be some difference.. ?

    Thanks.

  9. Re: Calculate the sum of all values in the stack

    Hello,

    > Question: What is the difference between
    > UserRPL and SysRPL ???

    UserRPL is a subset of SysRPL.

    The difference is that each UserRPL contains check-code for argument
    validation which leads to a significant speed penalty as *each*
    UserRPL checks for valid arguments.
    The advantage is that is almost impossible to crash the calculator
    while using UserRPL.

    SysRPL usually does not contain any error checking so the programmer
    is responsible that his program will not fail. If it fails the result
    will be a warmstart (in the less severe errors) or a complete memory
    wipe out.

    Below SysRPL is Saturn assembly which is the fastest (in the Saturn
    world, in the ARM based machines ARM assembly is way faster than
    Saturn assembly as the Saturn processors is emulated in this machines)
    but here you have to do *everything* by youself since your are working
    outside of the operating system.

    Do a search on SysRPL in this newsgroup and more answers will show up
    then you can read.

    HTH,
    Andreas
    http://www.software49g.gmxhome.de

  10. Re: Calculate the sum of all values in the stack

    On Wed, 25 Jun 2008 04:38:30 -0500, reth wrote:

    > what about \<< DEPTH \->LIST \GSLIST \>> ???


    Try it with a stack depth of either zero or one ;-)

    Whatever program you use, an additional thought
    is to return the NEGative of the actual sum,
    with an identifying "tag" (e.g. NEG "-Sum" \->TAG)

    You can then keep any number of independent sums on the stack,
    simulating one of those long forgotten "paperless printer" calcs,
    because each independent "section,"
    consisting of some values followed by the negative sum,
    totals zero, and thus does not affect subsequent sections.

    This can go slightly awry if the sets of values
    have many significant digits, and also
    widely differ in exponent range (powers of 10),
    where a "small" roundoff error in an earlier "section" can then
    start off a new "section" with a relatively large "imbalance,"
    but it will generally work fine for everyday accounting.

    If you want to be able to insert non-numeric items
    (e.g. heading strings like "Gas" "Food" etc. for your expense report)
    then also have your program bypass non-numerics while summing.

    E.g. here's a complete program for all HP48/49/50,
    accepting any stack,
    permitting multiple independent sums on the same stack:

    \<< 0 DEPTH 1. SWAP FOR i i PICK DTAG
    { 0. 28. } OVER TYPE POS { + } { DROP } IFTE
    NEXT NEG "-Sum" \->TAG \>> '\GSSTK' STO

    This handles empty and 1-item stacks, too.

    ---

    "Texas Instruments Paperless Printer" (1987-1996+)
    http://www.datamath.org/Desktop/PaperlessPrinter.htm
    http://www.datamath.org/Desktop/ti-5038.htm
    http://www.datamath.org/Desktop/ti-5028.htm

    [r->] [OFF]

  11. Re: Calculate the sum of all values in the stack

    On Jun 29, 7:30 am, "John H Meyers" wrote:
    > On Wed, 25 Jun 2008 04:38:30 -0500, reth wrote:
    > > what about \<< DEPTH \->LIST \GSLIST \>> ???

    >
    > Try it with a stack depth of either zero or one ;-)
    >
    > Whatever program you use, an additional thought
    > is to return the NEGative of the actual sum,
    > with an identifying "tag" (e.g. NEG "-Sum" \->TAG)
    >
    > You can then keep any number of independent sums on the stack,
    > simulating one of those long forgotten "paperless printer" calcs,
    > because each independent "section,"
    > consisting of some values followed by the negative sum,
    > totals zero, and thus does not affect subsequent sections.
    >
    > This can go slightly awry if the sets of values
    > have many significant digits, and also
    > widely differ in exponent range (powers of 10),
    > where a "small" roundoff error in an earlier "section" can then
    > start off a new "section" with a relatively large "imbalance,"
    > but it will generally work fine for everyday accounting.
    >
    > If you want to be able to insert non-numeric items
    > (e.g. heading strings like "Gas" "Food" etc. for your expense report)
    > then also have your program bypass non-numerics while summing.
    >
    > E.g. here's a complete program for all HP48/49/50,
    > accepting any stack,
    > permitting multiple independent sums on the same stack:
    >
    > \<< 0 DEPTH 1. SWAP FOR i i PICK DTAG
    > { 0. 28. } OVER TYPE POS { + } { DROP } IFTE
    > NEXT NEG "-Sum" \->TAG \>> '\GSSTK' STO
    >
    > This handles empty and 1-item stacks, too.
    >
    > ---
    >
    > "Texas Instruments Paperless Printer" (1987-1996+)http://www.datamath.org/Desktop/Pape...op/ti-5028.htm
    >
    > [r->] [OFF]


    the original post defines pretty clearly what's needed:
    "...trick to calculate the sum of all the existing values of the stack
    so I can avoid the use of the plus key all the time..."
    and the short answer is what I sugested; all the rest is an
    overkill
    So, how many times does one have to hit the plus key to get the sum of
    zero or one values?
    cheers,
    reth

  12. Re: Calculate the sum of all values in the stack

    On Sat, 28 Jun 2008 17:35:55 -0500, reth wrote:

    > the original post defines pretty clearly what's needed...
    > all the rest is an overkill


    Most people have low initial expectations,
    and can make do with any old calculator;
    the entire HP line is "overkill,"
    giving more capability, often appreciated
    by those who didn't even know that they could get more.

    If you object to seeing "added value,"
    read a more dumbed down newsgroup

    -[ ]-

  13. Re: Calculate the sum of all values in the stack

    On Jul 1, 6:11 am, "John H Meyers" wrote:
    > On Sat, 28 Jun 2008 17:35:55 -0500, reth wrote:
    > > the original post defines pretty clearly what's needed...
    > > all the rest is an overkill

    >
    > Most people have low initial expectations,
    > and can make do with any old calculator;
    > the entire HP line is "overkill,"
    > giving more capability, often appreciated
    > by those who didn't even know that they could get more.
    >
    > If you object to seeing "added value,"
    > read a more dumbed down newsgroup
    >
    > -[ ]-


    "the entire HP line is "overkill," I like that
    cheers,
    reth

+ Reply to Thread