Qbasicnews.com

Full Version: Rotate left 2 bits (like assembler)
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2 3 4 5 6 7 8 9 10
seems like we got a winner there
EDIT: Nevermind, this was a response to a post that was deleted/edited.
the sensible christian has spoken
Wrong topic?


So, do I win or not?
What do you mean no one? Smile
Mine inputs a 16 bit intger, negative or positive. Rotates to the left 2 bites and returns another integer, and complies to all the requirments Moneo had.

Moneo: Yeah, sure. Try 2^13 or any number that has bit 13 set.
Well, my solution is cooler.. cause.. it just is..

And you dont count anyways! :lol:
Oh, i forgot Smile
Z!re,

Your solution has to be considered the winner. Big Grin

Although at first glance it looks like a lot of code, it is very simple and straightforward code that is very easy to understand. In addition, by modifying only one line of code, it can perform other combinations of shifting/rotating, left or right.

Like you said, it can be made shorter by using a hex table lookup, and the conversion back from the 16 character rot$ string to decimal can also be done in a little loop.

One suggestion: In order to use your routine for multiple input values, you must set n$="" before the first FOR statement too.

Congratulation, Z!re. Thanks for contributing.
*****
About n$=""

It's meant to be in a function so..

n$ would be reassigned to "" each time it was called.. I didnt bother completing it though.. it works Tongue
Quote:What do you mean no one? Smile
Mine inputs a 16 bit intger, negative or positive. Rotates to the left 2 bites and returns another integer, and complies to all the requirments Moneo had.

Moneo: Yeah, sure. Try 2^13 or any number that has bit 13 set.
Blitz, I checked my solution and also Mango's. They both give the same results using all the combinations of the input value, with no overflow problems.

Please post the program using my solution which gives you an error, so I can take a look at it.
*****
Pages: 1 2 3 4 5 6 7 8 9 10