Java math help needed

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

    Java math help needed


    I need to recreate the following formula in java:

    INT((A2^3 + B2^3) / 100)) + MOD((A2^3 + B2^2), 100)

    Can someone show me how to do this in java?


    -Thanks

  • Yoyoma_2

    #2
    Re: Java math help needed

    Fred wrote:[color=blue]
    > I need to recreate the following formula in java:
    >
    > INT((A2^3 + B2^3) / 100)) + MOD((A2^3 + B2^2), 100)
    >
    > Can someone show me how to do this in java?
    >
    >
    > -Thanks
    >[/color]

    What do you mean by int? you mean integrate or what?

    Mod is % in java. so int i = 10 %5 = 0. 11 % 5 = 1 (if i remember
    correctly)

    To do powers you simply do Math.pow() look it up in your java api docs.
    Look for the Math class.

    Comment

    • Michael Scovetta

      #3
      Re: Java math help needed

      int answer = ((int)(pow(a2,3 ) + pow(b2,3)) / 100) +
      ((pow(a2,3) + pow(b2,2)) % 100);


      Fred <itfred@cdw.com > wrote in message news:<pan.2004. 03.25.03.57.00. 355201@cdw.com> ...[color=blue]
      > I need to recreate the following formula in java:
      >
      > INT((A2^3 + B2^3) / 100)) + MOD((A2^3 + B2^2), 100)
      >
      > Can someone show me how to do this in java?
      >
      >
      > -Thanks[/color]

      Comment

      • Huan Ding

        #4
        Re: Java math help needed

        All you need to do is to spend 10 mins reading your textbook, rather than
        posting your homework and waiting somebody to do it for you.

        HD


        "Fred" <itfred@cdw.com > wrote in message
        news:pan.2004.0 3.25.03.57.00.3 55201@cdw.com.. .[color=blue]
        >
        > I need to recreate the following formula in java:
        >
        > INT((A2^3 + B2^3) / 100)) + MOD((A2^3 + B2^2), 100)
        >
        > Can someone show me how to do this in java?
        >
        >
        > -Thanks
        >[/color]


        Comment

        • Tom N

          #5
          Re: Java math help needed

          "Yoyoma_2" wrote:[color=blue]
          > Fred wrote:[color=green]
          > > I need to recreate the following formula in java:
          > >
          > > INT((A2^3 + B2^3) / 100)) + MOD((A2^3 + B2^2), 100)
          > >
          > > Can someone show me how to do this in java?
          > >
          > >
          > > -Thanks
          > >[/color]
          >
          > What do you mean by int? you mean integrate or what?
          >
          > Mod is % in java. so int i = 10 %5 = 0. 11 % 5 = 1 (if i remember
          > correctly)[/color]

          Nitpick:

          % in Java is actually remainder, not Modulus.
          True Modulus produces a result from 0 to the divisor-1.
          % can produce negative results.

          "the % operator is not a true mod operator, but computes the remainder,
          which may be negative"

          [color=blue]
          > To do powers you simply do Math.pow() look it up in your java api docs.
          > Look for the Math class.[/color]


          Comment

          Working...