๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ
2022/์˜คํ”ˆ์†Œ์Šค ์†Œํ”„ํŠธ์›จ์–ด ํ”„๋กœ์ ํŠธ

float๊ฐ€ ์ •์ˆ˜์ธ์ง€ ํ™•์ธํ•˜๊ธฐ

by hyeonha 2022. 11. 27.

๋ชฉ์ฐจ

    http://daplus.net/python-float-%EA%B0%92%EC%9D%B4-%EC%A0%95%EC%88%98%EC%9D%B8%EC%A7%80-%ED%99%95%EC%9D%B8%ED%95%98%EB%8A%94-%EB%B0%A9%EB%B2%95/

     

    [python] float ๊ฐ’์ด ์ •์ˆ˜์ธ์ง€ ํ™•์ธํ•˜๋Š” ๋ฐฉ๋ฒ• - ๋ฆฌ๋ทฐ๋‚˜๋ผ

    ์ •์ˆ˜, ์ฆ‰ 12,000๋ณด๋‹ค ์ž‘์€ ๊ฐ€์žฅ ํฐ ํ๋ธŒ ๋ฃจํŠธ๋ฅผ ์ฐพ์œผ๋ ค๊ณ ํ•ฉ๋‹ˆ๋‹ค. processing = True n = 12000 while processing: n -= 1 if n ** (1/3) == #checks to see if this has decimals or not ์ •์ˆ˜์ธ์ง€ ์•„๋‹Œ์ง€ ํ™•์ธํ•˜๋Š” ๋ฐฉ๋ฒ•์„ ์ž˜ ๋ชจ๋ฅด๊ฒ 

    daplus.net

     def button_plus_minus_clicked(self):
            operation_solution=self.operation_solution.text()
            if float(operation_solution) >0:
                if float(operation_solution).is_integer:
                    operation_solution =int(operation_solution)*(-1)
                else:
                    operation_solution =float(operation_solution)*(-1)
            else:
                if float(operation_solution).is_integer:
                    operation_solution =int(operation_solution)*(-1)
                else:
                    operation_solution=float(operation_solution)*(-1)
            self.operation_solution.setText(str(operation_solution))
       

    (์ˆ˜).is_interger์„ ํ†ตํ•ด์„œ ์ •์ˆ˜์ธ์ง€ ์‹ค์ˆ˜์ธ์ง€ ํ™•์ธํ•  ์ˆ˜ ์žˆ๋‹ค.

     

    728x90