Quantcast

Re: converting binary string into integer

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: converting binary string into integer

Alberto Barradas
Hi guys,
Now that `parseint()` got removed for version 0.5, Is `parse()` the only way to do this?
 How could I parse binary into a BigInt? More specifically, I want to see the integer number of the arecibo message. (73x23 so 1679 binary digits into a big int)
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: converting binary string into integer

Milan Bouchet-Valat
Le dimanche 06 novembre 2016 à 10:13 -0800, Alberto Barradas a écrit :
> Hi guys,
> Now that `parseint()` got removed for version 0.5, Is `parse()` the
> only way to do this?
>  How could I parse binary into a BigInt? More specifically, I want to
> see the integer number of the arecibo message. (73x23 so 1679 binary
> digits into a big int)
parse() is meant to be called on Julia expressions.
Use parse(Int, ...) or parse(BigInt, ...) depending on your needs.



Regards
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: converting binary string into integer

David P. Sanders
In reply to this post by Alberto Barradas


El domingo, 6 de noviembre de 2016, 15:18:03 (UTC-5), Alberto Barradas escribió:
Hi guys,
Now that `parseint()` got removed for version 0.5, Is `parse()` the only way to do this?
 How could I parse binary into a BigInt? More specifically, I want to see the integer number of the arecibo message. (73x23 so 1679 binary digits into a big int)

julia> s = join(rand(0:1, 64))
"1001011000111000000010011110001010010001111110100101001111100111"

julia> parse(Int64, s, 2)
------ OverflowError ------------------- Stacktrace (most recent call last)

julia> parse(BigInt, s, 2)   # the 2 at the end is the base (here, binary)
10824412573101347815 
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: converting binary string into integer

Alberto Barradas

Thank you guys! This looks like a cleaner and more graceful solution!
Loading...