Hello, OnlineGDB Q&A section lets you put your programming query to fellow community users. Asking a solution for whole assignment is strictly not allowed. You may ask for help where you are stuck. Try to add as much information as possible so that fellow users can know about your problem statement easily.
Login
Login
OnlineGDB Q&A
Questions
Unanswered
Tags
Ask a Question
Ask a Question
How do I write a binary literal value into a variable?
+1
vote
asked
Jul 30, 2019
by
Jon
(
130
points)
I would like to be able to write binary values into variables. For example; int var = 10010101; Can anyone help me out?
Thank you!
binary
variable
value
Your answer
Your name to display (optional):
Email me at this address if my answer is selected or commented on:
Email me if my answer is selected or commented on
Privacy: Your email address will only be used for sending these notifications.
Anti-spam verification:
To avoid this verification in future, please
log in
or register.
2 Answers
0
votes
answered
Aug 1, 2019
by
Loki
(
1,600
points)
Well you can't it would just take it as an integer hence won't work like you want but you could do it with hexadecimel try this int var = 0x95
in binary 0x95 is 10010101.
There may be workarounds you may find on web.
Your comment on this answer:
Your name to display (optional):
Email me at this address if a comment is added after mine:
Email me if a comment is added after mine
Privacy: Your email address will only be used for sending these notifications.
Anti-spam verification:
To avoid this verification in future, please
log in
or register.
0
votes
answered
Aug 8, 2019
by
anonymous
You should write that as 0b10010101 (use prefix 0b when writing in base 2).
Your comment on this answer:
Your name to display (optional):
Email me at this address if a comment is added after mine:
Email me if a comment is added after mine
Privacy: Your email address will only be used for sending these notifications.
Anti-spam verification:
To avoid this verification in future, please
log in
or register.
Welcome to OnlineGDB Q&A, where you can ask questions related to programming and OnlineGDB IDE and and receive answers from other members of the community.
...