Shifting strings
ziplock
Posts: 9
I'm working a little bit 'o code, and I'm stumped.
I want to take a number (like this: 52034) and shift (multiply, divide, square root, add, subtract) one of the bits by a certain amount (i.e., take 52034, and add 2 to the 0)
How would I do this?
Any help would be appreciated!
-Adam
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Hey! I'm Adam.
But YOU can call me ziplock.
Blog: braindrink.wordpress.com
"The only problem with the gene pool is that there is no lifeguard." -David Gerrold
Post Edited (ziplock) : 9/23/2009 1:29:08 AM GMT
I want to take a number (like this: 52034) and shift (multiply, divide, square root, add, subtract) one of the bits by a certain amount (i.e., take 52034, and add 2 to the 0)
How would I do this?
Any help would be appreciated!
-Adam
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Hey! I'm Adam.
But YOU can call me ziplock.
Blog: braindrink.wordpress.com
"The only problem with the gene pool is that there is no lifeguard." -David Gerrold
Post Edited (ziplock) : 9/23/2009 1:29:08 AM GMT
Comments
Not sure what you mean. Is the 52034 actually a number; held in a variable as in x := 52034? If yes, then to get the zero to a 2, add 200. Other than that can you provide more information on what you are trying to do?
Perhaps if you look at the number as 10,000's, 1000's, 100's, 10's and (decimal) digits that might help but it's not clear what you want to do.
welcome to the propeller community !
Please write us what you want to do in the end.
It's a common phenomen that you have a detail-problem in mind and just ask for the detail.
From my experience here I can tell you in 99% of all cases when somebody tells what he wants
to do in the end. A lot of more, sometimes complete different and then more elegant solutions
can be found.
It needs much less time to read 10-20 sentences of a project-description than thinking about
does he mean in this way ? or that way ? .... hm guessing if he means X then a solution might be....
but if he means Y the solution will be ....
So feel free to write a project-description
best regards
Stefan
In other words we need more information to be of help.
I'm trying to create random-random numbers, as the beginning of a radio encryption system.
I'm generating two random numbers, using one to shift the other randomly, and then storing the result in ram.
he1957, I'm using RealRandom to generate a two numbers; one between 0.0001 and 9.9999 and one between 0 and 5. Then, I use FloatString to convert the one between 0.0001 and 9.9999 to an integer.
Kwinn, I'm storing the number in a long type variable. (long randVal)
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Hey! I'm Adam.
But YOU can call me ziplock.
Blog: braindrink.wordpress.com
"The only problem with the gene pool is that there is no lifeguard." -David Gerrold
in the attached archive is a demo how to manipulate characters in strings
best regards
Stefan