You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to julia...@googlegroups.com
I have a binary number in string
a ="0b1001100"
How can I convert this into integer?
Thanks for any help.
andrew cooke
unread,
Oct 29, 2013, 1:37:19 PM10/29/13
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to julia...@googlegroups.com
julia> parseint("0b1001"[3:], 2)
9
Patrick O'Leary
unread,
Oct 29, 2013, 1:37:19 PM10/29/13
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to julia...@googlegroups.com
julia> a = "0b1001100" "0b1001100" julia> parse(a) 0x4c
SYoon
unread,
Oct 29, 2013, 1:41:44 PM10/29/13
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to julia...@googlegroups.com
Great!
Thanks for both of you.
andrew cooke
unread,
Oct 29, 2013, 1:53:41 PM10/29/13
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to julia...@googlegroups.com
this confused me for a moment; if it also confuses you it's because julia parses non-decimal integers as unsigned, and prints unsigned integers as hex.
Stefan Karpinski
unread,
Oct 29, 2013, 2:04:46 PM10/29/13
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to julia...@googlegroups.com
I would highly recommend that if you only need to parse integers you use parseint rather than parse. It will be faster and much safer.
Patrick O'Leary
unread,
Oct 29, 2013, 2:30:23 PM10/29/13
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to julia...@googlegroups.com
On Tuesday, October 29, 2013 1:04:46 PM UTC-5, Stefan Karpinski wrote:
I would highly recommend that if you only need to parse integers you use parseint rather than parse. It will be faster and much safer.
Yes, that is generally more correct. You would need logic to handle prefixes, though, if they vary, unless that's been rolled into parseint()? I don't have an up-to-date Julia to play with atm (did this in the Forio web repl).
Stefan Karpinski
unread,
Oct 29, 2013, 2:40:13 PM10/29/13
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to julia...@googlegroups.com
That's not a bad idea – when the base isn't given, we could infer it from the prefix.
Stefan Karpinski
unread,
Oct 29, 2013, 5:13:54 PM10/29/13
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to julia...@googlegroups.com
Btw, my recent enhancements to parseint not only added overflow detection (modulo lack of 128-bit support in LLVM), but also added full support for base autodetection via 0b, 0o and 0x prefixes.
John Myles White
unread,
Nov 23, 2013, 12:32:26 PM11/23/13
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to julia...@googlegroups.com
Nice!
— John
Stefan Karpinski
unread,
Nov 23, 2013, 12:33:59 PM11/23/13
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Julia Users
It should be noted that the base autodetection only happens when the base is not explicitly given. If an explicit base is given, the number may only contain digits in that base.
Alberto Barradas
unread,
Nov 6, 2016, 3:18:03 PM11/6/16
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to julia-users
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)
Milan Bouchet-Valat
unread,
Nov 6, 2016, 4:14:03 PM11/6/16
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to julia...@googlegroups.com
parse() is meant to be called on Julia expressions.
Use parse(Int, ...) or parse(BigInt, ...) depending on your needs.
Regards
David P. Sanders
unread,
Nov 6, 2016, 5:03:49 PM11/6/16
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message