Skip to content

Instantly share code, notes, and snippets.

@xdevs23
Created August 30, 2023 22:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save xdevs23/6f490e1b4bb85acfb8cf779ae892d029 to your computer and use it in GitHub Desktop.
Save xdevs23/6f490e1b4bb85acfb8cf779ae892d029 to your computer and use it in GitHub Desktop.
val values = listOf(8988, -4412, 597, -1624, 597, -514, 597, -514, 597, -514, 597, -513, 597, -514, 597, -514, 597, -514, 600, -511, 597, -1624, 597, -1625, 597, -1625, 597, -1625, 597, -1625, 596, -1626, 596, -1625, 598, -1625, 597, -1625, 597, -1625, 597, -1625, 597, -514, 597, -514, 597, -514, 597, -515, 597, -514, 597, -514, 597, -514, 597, -514, 597, -1625, 597, -1625, 597, -1625, 597, -1625, 597, -1625, 597, -1625, 597, -1626, 599, -1623, 597, -514, 597, -514, 597, -514, 597, -514, 597, -514, 597, -514, 597, -514, 597, -514, 597, -1626, 597, -1625, 597, -1625, 596, -1626, 596)
val roundedValues = values.map { it.toFloat() / 100f }.map { it + (if (it < 0f) -0.5f else .5f) }.map { it.toInt() * 100 }
roundedValues.chunked(2).joinToString("") { "${it.joinToString(", ")},\n" }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment