float

  • floating-point literals

  • 4 bytes (32bits) ๋ฅผ ์ฐจ์ง€

  • ์†Œ์ˆ˜์  ๊ฐ’์„ ํ‘œํ˜„

  • suffix๋กœ f ํ˜น์€ F ๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ํ•ด๋‹น ๋ฆฌํ„ฐ๋Ÿด์˜ ํƒ€์ž…์„ ๋‚˜ํƒ€๋‚ผ ์ˆ˜ ์žˆ์Œ.

float num = 1.23456 // compiler error
float num = 1.23456f or float num 1.23456F`
float num = (float) 1.23456

``

  • ๋ณดํ†ต ์†Œ์ˆ˜์  ์•„๋ž˜ 6~7 ์ž๋ฆฌ๊นŒ์ง€ ์ •ํ™•ํ•˜๊ฒŒ ํ‘œํ˜„ํ•  ์ˆ˜ ์žˆ์Œ.

    • float num = 1.2345678f;

  • wrapper class ๋Š” Float

  • default value๋Š” 0.0f

[[double]] ๊ณผ ๋น„์Šทํ•œ ์ 

  • ๋‘˜ ๋‹ค ์ •ํ™•ํ•œ ๊ฐ’์„ ๋‚˜ํƒ€๋‚ด์ง„ ์•Š๋Š”๋‹ค.

  • ์ฆ‰ ์†Œ์ˆ˜์  ํ•œ์ž๋ฆฌ์ˆ˜๊ฐ€ ์ค‘์š”ํ•œ ํ†ตํ™”๋“ฑ์— ์‚ฌ์šฉํ•˜๋ฉด ์•ˆ๋œ๋‹ค.

    • [[floating-point]] ๋ฌธ์ œ

    • BigDecimal์‚ฌ์šฉ

  • = , != ๊ฐ™์€ ์ •ํ™•ํ•œ ๊ฐ’์„ ๋น„๊ตํ•˜๋Š” ๋…ผ๋ฆฌ ์—ฐ์‚ฐ์ž ์‚ฌ์šฉ์˜ ํ•ด๋‹น ํƒ€์ž…๋“ค์—์„œ ์‚ฌ์šฉ์„ ํ”ผํ•˜๋Š”๊ฒŒ ์ข‹์„๋“ฏ.

    • > , < ๋น„๊ต ์—ฐ์‚ฐ์ž๋Š” ๊ดœ์ฐฎ์„๋“ฏ..?

์ฐธ๊ณ 

Last updated