絶対値
| 日本語 | 絶対値 |
| 英語 | absolute value |
| ふりがな | ぜったいち |
| フリガナ | ゼッタイチ |
ある数値の、正の数値。
正の場合はそのままの値、負の場合には-1を掛けた値が、絶対値である。
たとえば「5」の絶対値は「5」であり、「-5」の絶対値は「5」である。
Javaでは、Mathクラスのabs()メソッドで絶対値を取得することができる。
正の場合はそのままの値、負の場合には-1を掛けた値が、絶対値である。
たとえば「5」の絶対値は「5」であり、「-5」の絶対値は「5」である。
Javaでは、Mathクラスのabs()メソッドで絶対値を取得することができる。
参考サイト
// Sample.java
public class Sample
{
public static void main( String[] args )
{
// -5 の絶対値を求めます。
int i = -5;
int result = Math.abs( i );
System.out.println( result );
// 5
}
}
public class Sample
{
public static void main( String[] args )
{
// -5 の絶対値を求めます。
int i = -5;
int result = Math.abs( i );
System.out.println( result );
// 5
}
}
// Sample.java
public class Sample
{
public static void main( String[] args )
{
// -5 の絶対値を求めます。
int i = -5;
int result = Math.abs( i );
System.out.println( result );
// 5
}
}




