OBtain Two Numbers from a single number
YOu are given any two numbers from 0 to 256.From this numbers u make a new number such that afterwards if only the new number is given u should get back the original two numbers..The new number and the original numbers are floating point numbers..They are integers
CAN ANY ONE FIND??I CHALLEENGE
Re: OBtain Two Numbers from a single number
i dont see what your looking for?
Re: OBtain Two Numbers from a single number
err........
I picked two numbers and came up with a new number of 465829293998.
What two numbers did I pick then? ;)
Seriously though...can you repeat the question again please?! :thumb:
Re: OBtain Two Numbers from a single number
One way:
Convert them both to binary, then append the second number to the first and convert the result back to decimal.
For example, given 1 and 2:
000000001 and 000000010
becomes: 000000010000000001 = 1025
Because you know that the numbers are between 1 and 256, you can convert to binary with a fixed number of digits, so to get the original number back you convert it to binary, take the first 9 digits and convert to give you the first number and take the second 9 digits to get the second number.
This, of course, would work equally well in any other base as long as you know how many digits are used in order to make the split.
zaza
PS: Homework, perchance? I'm not coding it for you!
Re: OBtain Two Numbers from a single number
Quote:
Originally Posted by zaza
One way:
Convert them both to binary, then append the second number to the first and convert the result back to decimal.
For example, given 1 and 2:
000000001 and 000000010
becomes: 000000010000000001 = 1025
Because you know that the numbers are between 1 and 256, you can convert to binary with a fixed number of digits, so to get the original number back you convert it to binary, take the first 9 digits and convert to give you the first number and take the second 9 digits to get the second number.
This, of course, would work equally well in any other base as long as you know how many digits are used in order to make the split.
zaza
PS: Homework, perchance? I'm not coding it for you!
but 3rd number is 1025 not between 0 and 256
Re: OBtain Two Numbers from a single number
Sure in zazas suggestion the third number has a value >then 1024, but you didn't tell us that that was suspected.
also what kind of a number is a floating point integer?????
Quote:
The new number and the original numbers are floating point numbers..They are integers
If you can't read your homework assignment, nobody will be able to help you.
Re: OBtain Two Numbers from a single number
Quote:
Originally Posted by soorejmg
but 3rd number is 1025 not between 0 and 256
zaza just posted a suggestion, if it (the LOGIC) seems relevant to you then use it according you to your need.
we can just give you suggestions, nobody will do your home-work here. you need to work on these logics to your need.
Harsh
Re: OBtain Two Numbers from a single number
If one of them is 0, then the other can be any number :)
Re: OBtain Two Numbers from a single number
If decimal values are allowed, this is dead easy. But I, too, am trying to figure out if it's a floating point number, or an integer. :)