Skip to content

Commit

Permalink
Correct Double.roundedToNearest calculation
Browse files Browse the repository at this point in the history
  • Loading branch information
patrickmichalik committed Aug 2, 2024
1 parent 0217a24 commit c034c86
Showing 1 changed file with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ package com.patrykandpatrick.vico.core.common

import androidx.annotation.RestrictTo
import kotlin.math.abs
import kotlin.math.ceil
import kotlin.math.floor
import kotlin.math.pow
import kotlin.math.roundToInt
import kotlin.math.sqrt
import kotlin.random.Random

Expand Down Expand Up @@ -92,7 +92,7 @@ internal inline val Int?.orZero: Int
get() = this ?: 0

internal inline val Double.roundedToNearest: Double
get() = roundToInt().toDouble()
get() = if (this % 1 >= 0.5) ceil(this) else floor(this)

internal inline val Float.piRad: Float
get() = this * PI_RAD
Expand Down

0 comments on commit c034c86

Please sign in to comment.