๋ฐ˜์‘ํ˜•

Non-terminating 1

[Kotlin] Error: Non-terminating decimal expansion; no exact representable decimal result. ์˜ค๋ฅ˜

Intro kotlin ๊ธฐ๋ฐ˜์˜ ์กฐํšŒ API๋ฅผ ๋งŒ๋“ค๋˜ ๋„์ค‘ ์•„๋ž˜์™€ ๊ฐ™์€ ์—๋Ÿฌ๊ฐ€ ๋ฐœ์ƒํ–ˆ์Šต๋‹ˆ๋‹ค. Non-terminating decimal expansion; no exact representable decimal result. Why? ๊ฐ’์„ ๊ตฌํ•˜๊ธฐ ์œ„ํ•ด divide๋ฅผ ํ†ตํ•ด ๋‘ BigDecimal ๊ฐ’์„ ๋‚˜๋ˆ ์ฃผ์—ˆ์Šต๋‹ˆ๋‹ค. ๋ถ„๋ช… ์—๋Ÿฌ๊ฐ€ ์—†์—ˆ๋Š”๋ฐ, ์™œ ์—๋Ÿฌ๊ฐ€ ๋ฐœ์ƒํ–ˆ๋Š”์ง€ ๊ตฌ๊ธ€๋ง์„ ํ•˜์—ฌ ๊ฒ€์ƒ‰ํ•ด๋ดค์Šต๋‹ˆ๋‹ค. BigDecimal ๋‚˜๋ˆ„๊ธฐ๋ฅผ ํ•  ๊ฒฝ์šฐ ์ •ํ™•ํ•œ ๊ฐ’์ด ๋–จ์–ด์ง€์ง€ ์•Š์œผ๋ฉด ๋‹ค์Œ์˜ "Non-terminating decimal expansion; no exact representable decimal result." ์—๋Ÿฌ๊ฐ€ ๋ฐœ์ƒํ•œ๋‹ค๊ณ  ํ•ฉ๋‹ˆ๋‹ค. ๊ธฐ์กด ํ…Œ์ŠคํŠธ ํ•˜๋˜ ๋ฐ์ดํ„ฐ์—์„œ๋Š” ์ •ํ™•ํžˆ ๊ฐ’์ด ๋–จ์–ด์ ธ ๋‚˜๋ˆ ์กŒ๊ธฐ ๋•Œ๋ฌธ์— ์—๋Ÿฌ๊ฐ€ ๋ฐœ์ƒํ•˜์ง€ ์•Š์•˜..

Programming/Kotlin 2023.01.02
๋ฐ˜์‘ํ˜•