ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

Reciprocal of a Number

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Reciprocal of a Number

    Hello,

    I am creating a report and I need to calcualate the reciprocal of a negative number. Can anyone think back to their algerbra days and tell me how I can come up with the reciprocal of 10.00- which would be 10.00.


    Thanks,

    DAC

  • #2
    Re: Reciprocal of a Number

    I thought reciprocals only deal with positives to fractions and back again.

    are you saying if the number is negative youd like to see it as positive

    if so then

    if number is less than *zeros
    number *= -1
    endif
    All my answers were extracted from the "Big Dummy's Guide to the As400"
    and I take no responsibility for any of them.

    www.code400.com

    Comment


    • #3
      Re: Reciprocal of a Number

      I thought the reciprocal of -10 = -.1 = 1/-10?

      If you are looking for the absolute use:
      PHP Code:

      number 
      = %Abs(number) ; 
      Predictions are usually difficult, especially about the future. ~Yogi Berra

      Vertical Software Systems
      VSS.biz

      Comment


      • #4
        Re: Reciprocal of a Number

        From Wikipedia,

        Reciprocal (mathematics), the number 1/x, which multiplied by x gives the product 1

        HTH,
        MdnghtPgmr
        "Tis better to be thought a fool then to open one's mouth and remove all doubt." - Benjamin Franklin

        Comment


        • #5
          Re: Reciprocal of a Number

          Now class.... let's get back to basics...

          1 + 1 = 2
          2 + 2 = 4
          3 + 3 = 6
          ...

          Comment


          • #6
            Re: Reciprocal of a Number

            Originally posted by jamief View Post
            if number is less than *zeros
            number *= -1
            endif
            We've had this discussion before! You know the one. About how subtracting a negative from zero gives the same result as multiplying by negative one, but at a fraction of the cost!

            Code:
            if number is less than *zeros
              number = 0 - number
            endif
            "Time passes, but sometimes it beats the <crap> out of you as it goes."

            Comment


            • #7
              Re: Reciprocal of a Number

              Personally I would move all numbers into a large character field then search the character field for a minus sign. If you find one, change it to a space and then move the entire field back into a numeric.

              Comment


              • #8
                Re: Reciprocal of a Number

                I have a headache......anyone know what I should take
                All my answers were extracted from the "Big Dummy's Guide to the As400"
                and I take no responsibility for any of them.

                www.code400.com

                Comment


                • #9
                  Re: Reciprocal of a Number

                  Originally posted by kpmac View Post
                  I thought the reciprocal of -10 = -.1 = 1/-10?
                  You're right. That is the reciprocal of -10.00
                  You don't stop playing games because you get old, You get old because you stop playing games!

                  Comment


                  • #10
                    Re: Reciprocal of a Number

                    I thought you multiplied it by 100.000001... or was that something else... heh
                    Hail to the king, baby.

                    Comment

                    Working...
                    X