-
I don't get it, how encode and decode work ? In the documentation we can read that Is |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Apologies for the lateness of my reply. I didn't realize there were discussions pending. Encode and decode are poorly explained but easy to understand and often handy. Consider a day: 24 hours of 60 minutes of 60 seconds. It is now 13:45:17. How many seconds have passed? 24 60 60 decode 13 45 17 And to invert: 24 60 60 encode 49517 Encode is a better place to start. We want to convert 49517 into a time, so we start with seconds, and find that 49517 modulo 60 is 17, while 49517 divided by 60, truncated, is 825. So we have 17 seconds for the last piece of our time stamp. Now we do the same to find the minutes, using 825. This gives us 825 mod 60 = 45, which is our minutes, leaving an hours value of 825/60 = 13. In other words, encode works from the right by doing successive (quotient, remainder) calculations, spitting out the remainder and continuing with the quotient. Decode is this exact process in reverse, which a little squinting will tell you is related to the evaluation of a polynomial. I hope that helps. |
Beta Was this translation helpful? Give feedback.
Thanks for the clarification !