From c38c37adbd0260cd5d5c9cd2ee120bb99f25ceb6 Mon Sep 17 00:00:00 2001 From: wonseok Date: Sun, 2 Feb 2025 00:59:06 +0900 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=A8=20Rounding=20temperature?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../karrot/manner/service/MannerService.kt | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/main/kotlin/com/toyProject7/karrot/manner/service/MannerService.kt b/src/main/kotlin/com/toyProject7/karrot/manner/service/MannerService.kt index ee7b62d..4ec5cf5 100644 --- a/src/main/kotlin/com/toyProject7/karrot/manner/service/MannerService.kt +++ b/src/main/kotlin/com/toyProject7/karrot/manner/service/MannerService.kt @@ -12,6 +12,8 @@ import com.toyProject7.karrot.user.controller.User import com.toyProject7.karrot.user.service.UserService import org.springframework.stereotype.Service import org.springframework.transaction.annotation.Transactional +import java.math.BigDecimal +import java.math.RoundingMode @Service class MannerService( @@ -54,9 +56,15 @@ class MannerService( } if (mannerType.name.startsWith("NEG_")) { - userEntity.temperature -= 0.1 + userEntity.temperature = + BigDecimal(userEntity.temperature - 0.1) + .setScale(1, RoundingMode.HALF_UP) + .toDouble() } else { - userEntity.temperature += 0.1 + userEntity.temperature = + BigDecimal(userEntity.temperature + 0.1) + .setScale(1, RoundingMode.HALF_UP) + .toDouble() } if (userEntity.temperature > 100) {