0

i am new in java ... i would like to know how 2 maintain an integer without having it to show the decimal after i manipulate it. Example:

int y = 5;
System.out.print(Math.pow(y,2));

it display 25.0 instead of 25 which i wan it to be. Help would be very appreciate :)

4
Contributors
7
Replies
8
Views
9 Years
Discussion Span
Last Post by javaAddict
0

Math.pow takes two floating-point numbers and returns a floating-point number

maybe you want to convert it to an int first?

0

i see... how can i convert floating-point into integer in this case?

0

Try something like this:

(int)Math.pow(y,2);

or

System.out.println((int)Math.pow(y,2));

if you want to print

0

i see, it works...thx... oh ya one more things i would like to know. How u make ur java code appeared with a different backgroud colour(in this forum)? i am also new in daniweb... i read the notice about bb code, but i am still dont understand ...

0

Right above the text area where you write your reply there are tools for writing in bold or underlying. The 3rd from the right which is a "#" symbol is the code tag. Click it and write your code inside the tags.

0

i m new to daniweb....i know this question is totally irrelevant to the topic but i need to know how to start a new thread ...?!!

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.