Invalid octal digit error
Solution 1
Octal numbers use the digits 0 to 7. Maybe the error could be the digit 9, and digit 8 in your number. If you want to pass the number '962833', try converting it first to a correct octal number with an online converter. Then add the leading '0' and pass it to your function.
Solution 2
0962833
is an octal number because of the leading zero, so you can't have digits higher than 7. If you need the leading zero, why can't you turn it into a string? Leading zeroes have no mathematical significance, so why should there be a way to represent them in a numerical type?
Paz Aricha
Updated on June 11, 2022Comments
-
Paz Aricha almost 2 years
Invalid octal digit error in Ruby, how do I by pass that? I have a number,
0962833
, which I need to send to an API but I can't send it since I get this invalid octal digit error.I need a work around for that without turning that number into a string, the zero can't be removed, it's a must.
-
Michael Kohl almost 12 yearsThere's no need for an online converter:
"0962833".to_i(10).to_s(8) => "3530421"
:-) -
Paz Aricha almost 12 yearsYou guys are right, it wasn't a number issue since I change it to a string, the problem was with my curl command. Thanks.