fluffy0301 / jay_jiwoo

1 stars 0 forks source link

Ch02EX07 #28

Open fluffy0301 opened 2 years ago

fluffy0301 commented 2 years ago

실수 타입의 변수

  • float (32bit)
  • 값을 대입 시 영문자 f 또는 F를 붙인다
  • double (64bit)
  • double 이 기본형. (아무생각없이 코딩하면 다 double이됨)
  • 소수점 9를 표현 하지못해서, 소수점 숫자 오류 가능성 있음.
  • float는 소수점 5번째까지 신뢰.
  • double 소수점 15번째까지 신뢰.
public class Ch02EX07 {

    public static void main(String[] args) {

    float floatVar1 = 0.9F,floatVar2 = 0.5F; 
    System.out.println(floatVar1);

    double doubleVar1= floatVar1; 
    System.out.println(doubleVar1);

    double doubleVar2 = floatVar1 + floatVar2;
    System.out.println(doubleVar2);

    }//main

}//class