Professional Documents
Culture Documents
12 Numbers
12 Numbers
Java SE
Contents
• Number Classes
• Formatting Numbers
Getting Converting to
Comparing Check Equality
Primitives other types
Getting Primitives
Return Type Method
byte byteVaue()
short shortValue()
int intValue()
long longValue()
float floatValue()
double doubleValue()
Comparing
Return Type Method
int compare(Byte anotherByte)
int compare(Short anotherShort)
int compare(Integer anotherInteger)
int compare(Long anotherLong)
int compare(Float anotherFloat)
int compare(Double anotherDouble)
Check Equality
Return Type Method
boolean equals(Object obj)
Convert to other types
Method Description
String မ"eန Inetger အ&ဖစ)e&ပ+င)-လည)- eပ-0iuင)ပ3သည)။
Decimal, Octal 0"င)6 Hexdecimal ပu7စ7&ဖင)6 eဖ+)&ပထ+-eသ+
static Integer decode(String s)
String မ9+-အ+- Integer အ&ဖစ)e&ပ+င)-လည)- eပ-0iuင)
ပ3သည)။
+ အeပ*င1#အ>Eတ1လကGဏ"အ"# 'ဖည1:စAက1eပ#မည1
- ဘယ1ဘက1သiuစu၍ eဖ"1'ပမည1
.3 ဒသမကiန1#၃လu&#အ"# eဖ"1'ပမည1
double pi = Math.PI;
Calendar c = Calendar.getInstance();
// "March 12, 2014"
System.out.format("%tB %te, %tY%n", c,c,c);
// "03/12/14"
System.out.format("%tD%n", c);
}
DecimalFormat
public static void main(String[] args) {
DecimalFormat df = new DecimalFormat("###,###,##0.000");
System.out.println(df.format(Math.sin(12)));
}
Exponential and
Basic Methods Trigonometric
Logarithmic
Basic Methods
Method Description
double abs(double d)
Argument ၏ Absolute Value အ+- &ပန)လည)ရTiမည)။
float abs(float f)
int abs(int i)
long abs(long l)
double ceil(double d) Argument ထက)XကQ-eသ+ သiuမဟuတ) တKညQeသ+ အeသ-ဆu7-
Integer အ+- double ပu7စ7&ဖင)6&ပန)လည)ရTiမည)။
double max(double arg1, double arg2) Argument 0"စ)ခu၏ အXကQ-ဆu7- Argument အ+-
float max(float arg1, float arg2) &ပန)လည)ရTiမည) &ဖစ)သည)။
int max(int arg1, int arg2)
long max(long arg1, arg2)
Sample Codes
double a = -191.635;
double b = 43.74;
int c = 16, d = 45;
double pow(double base, double Argument base အ+- exponent &ဖင)6 ထပ)ကiန)-တင)၍
exponent) တန)ဖiu-အ+-T+eဖ<ရ+တ<င) အသu7-&ပu0iuင)ပ3သည)။
• Math ၏ random method သည) 0.0 <= Math.random() < 1.0 အDက+-Ti
Random န7ပ3တ)တစ)ခuအ+- Retun တန)ဖiu- အeနန"င)6 &ပန)eပ-0iuင)မည) &ဖစ)
ပ3သည)။