Welcome! Log In Create A New Profile

Advanced

Assignment 2 question 8

Posted by ROtti 
Announcements Last Post
Announcement SoC Curricula 09/30/2017 01:08PM
Announcement Demarcation or scoping of examinations and assessment 02/13/2017 07:59AM
Announcement School of Computing Short Learning Programmes 11/24/2014 08:37AM
Announcement Unisa contact information 07/28/2011 01:28PM
avatar Assignment 2 question 8
May 04, 2009 05:10PM
How do you input a binary number into a function? Or can we input it as a string? "00110101" and then use the string methods? How should i go about this?
Re: Assignment 2 question 8
May 11, 2009 11:35AM
I used C_Strings and it worked like a charm, strings can also work but they require more time to implement.

--------------------------------------------------------------------
In a long journey, even a matchstick is heavy...
avatar Re: Assignment 2 question 8
May 11, 2009 12:27PM
I read it in as an integer, and used the mod operator to get the binary digit...
Re: Assignment 2 question 8
May 13, 2009 11:37AM
Did that work out? bcoz i also tried that out but my problem was that u need to know how many times you need to use the mod and div operator during design time, which i found was a bit tricky, thats why i ended up using C_Strings.

--------------------------------------------------------------------
In a long journey, even a matchstick is heavy...
avatar Re: Assignment 2 question 8
May 13, 2009 01:02PM
<No, not really. The base case is when Mod 2 = 1 AND Div 2 = 0. Then you know you are left with 1.> --- Scrap that nonsense. I was on the typing before I was thinking.
avatar Re: Assignment 2 question 8
May 13, 2009 01:29PM
Yeah it works, when the binary number is equal to zero, then it's done, 000101 is the same as 101 smiling smiley
Sorry, only registered users may post in this forum.

Click here to login