HTTP/2 302
server: nginx
date: Thu, 24 Jul 2025 17:49:00 GMT
content-type: text/plain; charset=utf-8
content-length: 0
x-archive-redirect-reason: found capture at 20080302011528
location: https://web.archive.org/web/20080302011528/https://java.sun.com/developer/codesamples/math.html
server-timing: captures_list;dur=0.417138, exclusion.robots;dur=0.012657, exclusion.robots.policy;dur=0.006001, esindex;dur=0.009693, cdx.remote;dur=36.570575, LoadShardBlock;dur=4092.782745, PetaboxLoader3.datanode;dur=3968.401417, PetaboxLoader3.resolve;dur=113.771340
x-app-server: wwwb-app222
x-ts: 302
x-tr: 4161
server-timing: TR;dur=0,Tw;dur=0,Tc;dur=0
set-cookie: SERVER=wwwb-app222; path=/
x-location: All
x-rl: 0
x-na: 0
x-page-cache: MISS
server-timing: MISS
x-nid: DigitalOcean
referrer-policy: no-referrer-when-downgrade
permissions-policy: interest-cohort=()
HTTP/2 200
server: nginx
date: Thu, 24 Jul 2025 17:49:01 GMT
content-type: text/html
x-archive-orig-server: Sun-Java-System-Web-Server-6.1
x-archive-orig-date: Sun, 02 Mar 2008 01:15:27 GMT
x-archive-orig-last-modified: Mon, 17 Dec 2007 23:44:47 GMT
x-archive-orig-accept-ranges: bytes
x-archive-orig-connection: close
x-archive-guessed-content-type: text/html
x-archive-guessed-charset: iso-8859-1
memento-datetime: Sun, 02 Mar 2008 01:15:28 GMT
link:
; rel="original", ; rel="timemap"; type="application/link-format", ; rel="timegate", ; rel="first memento"; datetime="Wed, 17 Dec 2003 15:53:43 GMT", ; rel="prev memento"; datetime="Tue, 29 Jan 2008 09:02:07 GMT", ; rel="memento"; datetime="Sun, 02 Mar 2008 01:15:28 GMT", ; rel="next memento"; datetime="Wed, 26 Mar 2008 00:07:55 GMT", ; rel="last memento"; datetime="Sun, 25 Dec 2011 05:26:54 GMT"
content-security-policy: default-src 'self' 'unsafe-eval' 'unsafe-inline' data: blob: archive.org web.archive.org web-static.archive.org wayback-api.archive.org athena.archive.org analytics.archive.org pragma.archivelab.org wwwb-events.archive.org
x-archive-src: 52_2_20080301230750_crawl107-c/52_2_20080302011511_crawl104.arc.gz
server-timing: captures_list;dur=0.995593, exclusion.robots;dur=0.051467, exclusion.robots.policy;dur=0.022458, esindex;dur=0.016844, cdx.remote;dur=23.366012, LoadShardBlock;dur=435.503975, PetaboxLoader3.datanode;dur=205.356475, PetaboxLoader3.resolve;dur=427.006019, load_resource;dur=324.136486
x-app-server: wwwb-app222
x-ts: 200
x-tr: 853
server-timing: TR;dur=0,Tw;dur=0,Tc;dur=0
x-location: All
x-rl: 0
x-na: 0
x-page-cache: MISS
server-timing: MISS
x-nid: DigitalOcean
referrer-policy: no-referrer-when-downgrade
permissions-policy: interest-cohort=()
content-encoding: gzip
Math & Number Operations Code Samples
Index of Code Samples
Math & Number Operations Code Samples
Learn how to use numbers and math operations in applications written in the
Java programming language.
- BasicMathDemo.java
illustrates how to get the absolute value, ceiling value, floor value, and relative integer value.
For supporting information see
The Java Tutorial:
Object Basics and Simple Data Objects.
- DecimalFormatDemo.java
formats decimal numbers into strings.
For supporting information see
The Java Tutorial:
Object Basics and Simple Data Objects.
- ExponentialDemo.java
displays the exponent value and calls the
exp , log , pow , and
sqrt methods on it.
For supporting information see
The Java Tutorial:
Object Basics and Simple Data Objects.
- MinDemo.java
finds the smaller of two values.
For supporting information see
The Java Tutorial:
Object Basics and Simple Data Objects.
- NumberDemo.java
creates two
Float objects and one Double object.
For supporting information see
The Java Tutorial:
Object Basics and Simple Data Objects.
- Numbers.java
shows you how to perform various math operations on numbers received from the command line.
For supporting information see
New to Java Programming
Supplement, October 2001.
- RandomBagDemo.java
generates random numbers.
For supporting information see
The Java Tutorial:
Object Basics and Simple Data Objects.
- ScoresAverage.java
shows you how to store numbers in an array and compute the average.
For supporting information see
New to Java Programming
Supplement, August 2001.
- ToStringDemo.java
uses the
toString method to convert a number to a string, and uses some string methods
to compute the number of digits before and after the decimal point.
For supporting information see
The Java Tutorial:
Object Basics and Simple Data Objects.
- TrigonometricDemo.java
computes various trigonometric values for a 45-degree angle.
For supporting information see
The Java Tutorial:
Object Basics and Simple Data Objects.
- ValueOfDemo.java
gets two strings from the command line, converts them to numbers, and performs arithmetic operations
on the value.
For supporting information see
The Java Tutorial:
Object Basics and Simple Data Objects.
|
 |