Skip to content

How to round up the light year #131

Answered by PaddiM8
sergeevabc asked this question in Q&A
Discussion options

You must be logged in to vote

Ah well for integers it would be truncate(x, n) = floor(x / 10^(floor(log(x)) - n)) * 10^floor(log(x) - n) I think. A bit more complicated, but 10^(floor(log(x)) - n) could be its own function to make it more readable.

Replies: 1 comment 10 replies

Comment options

You must be logged in to vote
10 replies
@sergeevabc
Comment options

@PaddiM8
Comment options

@sergeevabc
Comment options

@PaddiM8
Comment options

Answer selected by sergeevabc
@sergeevabc
Comment options

@PaddiM8
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants