Invalid octal error

Invalid octal error in Ruby, how do I pass this? I have a number, 0962833 , which I need to send to the API, but I cannot send it, since I am getting this invalid octal digital error.

I need work for this, without turning this number into a string, zero cannot be deleted, this is mandatory.

+4
source share
2 answers

Round numbers use numbers from 0 to 7. Perhaps the error may be the number 9 and the number 8 in your number. If you want to transfer the number "962833", try first converting it to the correct octal number using the online converter. Then add the leading "0" and pass it to your function.

+5
source

0962833 is an octal number due to a leading zero, so you cannot have digits above 7. If you need a leading zero, why can't you turn it into a string? Leading zeros have no mathematical value , so why should there be a way to represent them in a numerical type?

+3
source

All Articles