is there a reason why to make mix numbers improper when adding?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • sp0

    is there a reason why to make mix numbers improper when adding?

    Is there a reason why to make mix numbers improper when adding?

    It seems when subtracting and adding, adding a subtracting the whole
    numbers and fraction parts should be sufficient? what'ch think

  • Mike Wahler

    #2
    Re: is there a reason why to make mix numbers improper when adding?


    "sp0" <anonymous@anon ymous.com> wrote in message
    news:Xns949EE45 F2749Bspockieve rizonnet@199.45 .49.11...[color=blue]
    > Is there a reason why to make mix numbers improper when adding?
    >
    > It seems when subtracting and adding, adding a subtracting the whole
    > numbers and fraction parts should be sufficient? what'ch think[/color]

    Please give a specific code example of what you mean.
    I don't understand your questions.

    -Mike


    Comment

    • sp0

      #3
      Re: is there a reason why to make mix numbers improper when adding?

      [color=blue]
      > Please give a specific code example of what you mean.
      > I don't understand your questions.
      >[/color]


      temp.whole = whole - obj2.whole;
      temp.numer = ((whole * denom + numer)*obj2.den om) - ((obj2.whole *
      obj2.denom + obj2.numer)*den om);

      temp.denom = denom * obj2.denom;

      temp.reduce();



      subtracting the wholes instead of making both fractions improper

      Comment

      • Mike Wahler

        #4
        Re: is there a reason why to make mix numbers improper when adding?


        "sp0" <anonymous@anon ymous.com> wrote in message
        news:Xns949EEF6 E6E8FFspockieve rizonnet@199.45 .49.11...[color=blue]
        >[color=green]
        > > Please give a specific code example of what you mean.
        > > I don't understand your questions.
        > >[/color]
        >
        >
        > temp.whole = whole - obj2.whole;
        > temp.numer = ((whole * denom + numer)*obj2.den om) - ((obj2.whole *
        > obj2.denom + obj2.numer)*den om);
        >
        > temp.denom = denom * obj2.denom;
        >
        > temp.reduce();
        >
        >
        >
        > subtracting the wholes instead of making both fractions improper[/color]

        So what other method would you propose? Does it produce
        correct results?

        -Mike


        Comment

        • Virgil

          #5
          Re: is there a reason why to make mix numbers improper when adding?

          In article <Xns949EE45F274 9Bspockieverizo nnet@199.45.49. 11>,
          sp0 <anonymous@anon ymous.com> wrote:
          [color=blue]
          > Is there a reason why to make mix numbers improper when adding?
          >
          > It seems when subtracting and adding, adding a subtracting the whole
          > numbers and fraction parts should be sufficient? what'ch think
          >[/color]

          It need not be done that way, but when multiplying or dividing mixed
          numbers it is much easier to do in improper fraction form.

          Comment

          • William Elliot

            #6
            Re: is there a reason why to make mix numbers improper when adding?

            On Mon, 1 Mar 2004, sp0 wrote:
            [color=blue]
            > Is there a reason why to make mix numbers improper when adding?
            >
            > It seems when subtracting and adding, adding a subtracting the whole
            > numbers and fraction parts should be sufficient? what'ch think
            >[/color]
            75/7 * 77/5

            Comment

            • John Harrison

              #7
              Re: is there a reason why to make mix numbers improper when adding?


              "sp0" <anonymous@anon ymous.com> wrote in message
              news:Xns949EEF6 E6E8FFspockieve rizonnet@199.45 .49.11...[color=blue]
              >[color=green]
              > > Please give a specific code example of what you mean.
              > > I don't understand your questions.
              > >[/color]
              >
              >
              > temp.whole = whole - obj2.whole;
              > temp.numer = ((whole * denom + numer)*obj2.den om) - ((obj2.whole *
              > obj2.denom + obj2.numer)*den om);
              >
              > temp.denom = denom * obj2.denom;
              >
              > temp.reduce();
              >
              >
              >
              > subtracting the wholes instead of making both fractions improper[/color]

              You will get help on this group, if you post compilable code, say what you
              expect the code to produce, and what it produces instead.

              At the moment no-one has very much idea what your problem is.

              This is covered in the FAQ, 'How to I post a question about code that
              doesn't work correctly?'



              john


              Comment

              • Ken Pledger

                #8
                Re: is there a reason why to make mix numbers improper when adding?

                In article <Xns949EE45F274 9Bspockieverizo nnet@199.45.49. 11>,
                sp0 <anonymous@anon ymous.com> wrote:
                [color=blue]
                > ....
                > It seems when subtracting and adding, adding a subtracting the whole
                > numbers and fraction parts should be sufficient? what'ch think[/color]


                That's how I was taught to do it in primary school long ago.

                Ken Pledger.

                Comment

                • Buster

                  #9
                  Re: is there a reason why to make mix numbers improper when adding?

                  sp0 wrote:
                  [color=blue]
                  > Is there a reason why to make mix numbers improper when adding?[/color]

                  Is there a reason to store a fraction as a whole number and a fractional
                  part? Doesn't it lead to a lot of unnecessary complications (like this
                  one) in your code?
                  [color=blue]
                  > It seems when subtracting and adding, adding a subtracting the whole
                  > numbers and fraction parts should be sufficient? what'ch think[/color]

                  Adding or subtracting the fractional parts will be formally exactly the
                  same as adding or subtracting two improper fractions. All a mixed
                  representation does is add complexity.

                  I suggest you store rationals as numerator-denominator and produce
                  mixed-fraction representations only as required. Or let the user produce
                  them herself. She has access to the (coprime) numerator and denominator
                  and can calculate the quotient and remainder from them, right?

                  Regards,
                  Buster.

                  Comment

                  • juuitchan@hotmail.com

                    #10
                    Re: is there a reason why to make mix numbers improper when adding?

                    Buster <noone@nowhere. com> wrote in message news:<c20p0o$mn 1$1@newsg4.svr. pol.co.uk>...[color=blue]
                    > sp0 wrote:
                    >[color=green]
                    > > Is there a reason why to make mix numbers improper when adding?[/color]
                    >
                    > Is there a reason to store a fraction as a whole number and a fractional
                    > part? Doesn't it lead to a lot of unnecessary complications (like this
                    > one) in your code?
                    >[color=green]
                    > > It seems when subtracting and adding, adding a subtracting the whole
                    > > numbers and fraction parts should be sufficient? what'ch think[/color]
                    >
                    > Adding or subtracting the fractional parts will be formally exactly the
                    > same as adding or subtracting two improper fractions. All a mixed
                    > representation does is add complexity.
                    >
                    > I suggest you store rationals as numerator-denominator and produce
                    > mixed-fraction representations only as required. Or let the user produce
                    > them herself. She has access to the (coprime) numerator and denominator
                    > and can calculate the quotient and remainder from them, right?[/color]

                    Why not also leave numbers in binary or hexadecimal form for her?
                    Can't she convert them to decimal herself?

                    The needs of the machine and the needs of the human are different.
                    Have the machine use whatever format is most efficient for its own
                    work, and have it perhaps convert to another format to show the human.
                    Why on earth would she care how the computer stores the numbers, as
                    long as the answers come out right? Do you care what makes the sun
                    shine, or is it enough to know that it shines and will almost
                    certainly continue to shine for billions of years?
                    [color=blue]
                    >
                    > Regards,
                    > Buster.[/color]

                    Comment

                    • Buster

                      #11
                      Re: is there a reason why to make mix numbers improper when adding?

                      juuitchan@hotma il.com wrote:[color=blue]
                      > Buster <noone@nowhere. com> wrote in message news:<c20p0o$mn 1$1@newsg4.svr. pol.co.uk>...
                      >[color=green]
                      >>sp0 wrote:
                      >>
                      >>[color=darkred]
                      >>>Is there a reason why to make mix numbers improper when adding?[/color]
                      >>
                      >>Is there a reason to store a fraction as a whole number and a fractional
                      >>part? Doesn't it lead to a lot of unnecessary complications (like this
                      >>one) in your code?
                      >>[color=darkred]
                      >>>It seems when subtracting and adding, adding a subtracting the whole
                      >>>numbers and fraction parts should be sufficient? what'ch think[/color]
                      >>
                      >>Adding or subtracting the fractional parts will be formally exactly the
                      >>same as adding or subtracting two improper fractions. All a mixed
                      >>representatio n does is add complexity.
                      >>
                      >>I suggest you store rationals as numerator-denominator and produce
                      >>mixed-fraction representations only as required. Or let the user produce
                      >>them herself. She has access to the (coprime) numerator and denominator
                      >>and can calculate the quotient and remainder from them, right?[/color]
                      >
                      > Why not also leave numbers in binary or hexadecimal form for her?
                      > Can't she convert them to decimal herself?[/color]

                      It goes without saying that the numbers will be returned in binary form
                      in the scheme I have described. Are you suggesting that the value of
                      "a+b" (where a and b are rationals) should be a string? By all means
                      provide utility functions to create string representations in whatever
                      format you like, but they won't be used until after the users have
                      finished their calculations, and those calculations will in general be
                      simpler to program if you use the simpler numerator-denominator
                      representation.
                      [color=blue]
                      > The needs of the machine and the needs of the human are different.[/color]

                      Not in any essential way, when it comes to calculating with integers.
                      [color=blue]
                      > Have the machine use whatever format is most efficient for its own
                      > work, and have it perhaps convert to another format to show the human.[/color]

                      What's your point? What's wrong with the numerator-denominator format?
                      That's how I prefer to write fractions when calculating on paper, the
                      reasons being essentially the same as the reasons that I would use that
                      format internally in a rational number class.
                      [color=blue]
                      > Why on earth would she care how the computer stores the numbers, as
                      > long as the answers come out right?[/color]

                      The concept of a rational number is defined in terms of a numerator and
                      denominator. It really is, honest. A rational number is an equivalence
                      class of ordered pairs (a, b) where a and b are integers, b is nonzero
                      and (a, b) is defined to be equivalent to (c, d) if and only a*d == b*c.
                      Anyone who provides me with a rational number class had better assume
                      I'm going to be interested in obtaining a numerator and denominator from
                      an instance.

                      Given two rational number classes I would try, /ceteris paribus/, to
                      choose the more efficient. If this were independent of the internal
                      representation then fine, but it isn't.
                      [color=blue]
                      > Do you care what makes the sun
                      > shine, or is it enough to know that it shines and will almost
                      > certainly continue to shine for billions of years?[/color]

                      Sure I care what makes the sun shine. Where's your childlike wonder? If
                      everyone thought like that we'd all still be in dark ages.
                      [color=blue][color=green]
                      >>Regards,
                      >>Buster.[/color][/color]

                      Comment

                      Working...