Skip to content

Math Class

August 18, 2013

The Math Class is already defined in the java Package. There are a lot of methods for the Math Class but below are the list what i usually use:

  1. abs(x) = always outputs positive number
  2. ceil(x) = x is round down
  3. floor(x) = x is round up
  4. max(x, y)
  5. min(x, y)
  6. pow(x, y) = x is the base
  7. random() = output random no. ;
  8. random() * 255 = output random between 254


To only declare the method Name without specifying the class, you need to declare:

import static java.lang.Math.*;

Example on how to use any method of the math class:

int z = (int) pow(2, 3);

To Classify the Math Class, declare:

import java.lang.*;

Example to use the method the the kind of declaration above:

int z = (int) Math.pow(2, 4);

these are all things i know about Math Class

Advertisements
3 Comments
  1. Great post…

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

TurtleAndRobot.com

Children's Book Reviews

Malav Shah

official Web Site

My Road to Programming

The journey of how I taught myself to program.

paritoshmishra

Look at what's brewing up guys! we all are work in progress. So don't meander, lets micromesh everything and have candid conversation about every problem related to C, C++ and JAVA. We can rejuvenate the crinkled faces.

ProgramThat;

A simple guide to programming...

ITechonology

Information Techonology

Rahul's Work

My Work Tips and Tutorial on Various Tech.

Turnip Farmers

Kingdom Scans

Gigaom

Technology news, trends and analysis covering mobile, big data, cloud, science, energy and media

The Neighborhood

society online's social conscious

HarsH ReaLiTy

A Good Blog is Hard to Find

VentureBeat

News About Tech, Money and Innovation

retireediary

The Diary of a Retiree

50 Year Project

My challenge to visit 192 countries, read 1,001 books, and watch the top 100 movies

[BTW] : Ben Trube, Writer

Writer, Programmer, Singer

My Arch Walkthrough

Arch linux made easy

Don Charisma

because anything is possible with Charisma

SutoCom Solutions

Success & Satisfaction with the Cloud

%d bloggers like this: