By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,808 Members | 1,481 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,808 IT Pros & Developers. It's quick & easy.

Java math help needed

P: n/a

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

Jul 17 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
Fred wrote:
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


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.

Jul 17 '05 #2

P: n/a
int answer = ((int)(pow(a2,3) + pow(b2,3)) / 100) +
((pow(a2,3) + pow(b2,2)) % 100);
Fred <it****@cdw.com> wrote in message news:<pa****************************@cdw.com>...
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

Jul 17 '05 #3

P: n/a
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" <it****@cdw.com> wrote in message
news:pa****************************@cdw.com...

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

Jul 17 '05 #4

P: n/a
"Yoyoma_2" wrote:
Fred wrote:
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

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)


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"
http://java.sun.com/docs/books/jls/assert-spec.html
To do powers you simply do Math.pow() look it up in your java api docs.
Look for the Math class.

Jul 17 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.