So apparently i cant math. I'm doing some stuff wh...
# random
c
So apparently i cant math. I'm doing some stuff where I have 1 second to the pow of 5. That equals 1. but now i need ms instead of sec. and 1000 ^ 5 is like 100000000000000. do I need to divide the pow by like 1000 or something? lol. maybe i need sleep.
s
What do you mean by having "1 second to the pow of 5"?
are you describing a function that takes
n
seconds and raises it to the fifth power?
c
yeah. i have a function that takes n seconds and raises it to the fifth power. everything works fine with it. and all expected cases (like 1 second) to the fifth power, should equal 1. but now i need to convert to mills so if I take in 1000 millis, i still need 1000 as the output of the func
s
I guess you could convert to a BigDecimal, divide by 1000 to convert to seconds, do your arithmetic with seconds as normal, and then multiply by 1000 and convert to an int to yield milliseconds
there's potential for loss in precision in that process though, something to keep in mind
kinda seems like overkill though, depending on what exactly you need
c
int to yeild
whats that mean?
precision isn't too important. but it has to be in the ballpark
s
I mean "multiply your BigDecimal by 1000 and convert it back to an
Int
in order to yield `milliseconds`"
1
c
gotcha. alright. let me try to see what i can come up with.
i think my issue will be that something like the result of 0.5 to the power of 5 is not what i want. but 500ms to the power of 5 also is'nt what i want. hmm
who knew taking an existing func that deals with seconds and converting to millis would give me a headache. lol
s
hmm, true
I think typically you'd write the method for milliseconds first and then do conversions to accept seconds lol
c
my contraint here is basically i have tests already written and so they cant break. they already verify that the inputs and outputs (currently in seconds) are what they should be.
k
A typical example: 1 cubic metre = 1,000,000 cubic centimetres. 1 m³ = 100³ cm³ Note how the power applies to the units too. But... What on Earth does seconds to the power of 5 represent? It sounds very fishy. How can that possibly be useful?
👆 1
c
I wish I knew @Klitos Kyriacou lol I'm just picking up from an existing codebase. But this convo at least made me realize I wasn't going crazy and missing something simple. Thanks everyone. Glad I asked the question
m
What on Earth does seconds to the power of 5 represent?
1m/s = I moved 1 meter in a second 1m/s^2 = Every second I increased my movement speed by 1m/s 1m/s^3 = Every second I increased my acceleration rate by 1m/s^2 1m/s^4 = Every second I increased the rate of increase of my acceleration by 1m/s^3 1m/s^5 = Every second I increased the rate of increase of the rate of increase of my acceleration by 1m/s^4
Far fetched when you get to ^5, but not unreal.
👍 1
c
Lol. I wish I knew. I didn't write this. I just got the instructions to change it.