Thanks. Without the R6 = R6 - 1 it's definitely wrong most of the time. That's the difference between 1's complement and 2's complement arithmetic. (I think your -512 is a particularly favorable boundary case with no remainder.)
-1 \ 256 = 0 (with a remainder of -1). That would give you x'FFFFFFFF' going to 0. So I need to do something else also, but I'm not sure what. Anyone? (BTW, my apologies for the extra blank lines in the OP -- Outlook strikes again!) Charles -----Original Message----- From: IBM Mainframe Discussion List [mailto:[EMAIL PROTECTED] On Behalf Of Bill Godfrey Sent: Wednesday, February 21, 2007 2:26 PM To: [email protected] Subject: Re: Simulating SRL in integer arithmetic On Wed, 21 Feb 2007 10:48:10 -0800, Charles Mills wrote: > ' Simulate a shift right logical 8 > If R6 >= 0 Then > R6 = R6 \ 256 ' \ is integer division > Else > R6 = R6 \ 256 ' \ is integer division > R6 = R6 - 1 > R6 = R6 And &HFFFFFF ' Equivalent to S/390 X'FFFFFF' > End If I don't think you want the "R6 = R6 - 1". And if you drop it, you may as well rethink whether you want the if/else at all, and just do the "And" whether it's needed or not. I'm not a mathematician, nor do I know Visual Basic, but the result produced by this VBS script may be relevant. R6 = -512 R6 = R6 \ 256 And &Hffffff Wscript.echo R6 I'm pretty sure this script uses signed 32-bit integers, because it won't run if i try to set R6 to a value > 2147483647. I picked -512 (hex fffffe00) as a test value, expecting a result of hex 00fffffe which is decimal 16777214, and 16777214 is indeed the result displayed by "cscript srl.vbs" from the command prompt. ---------------------------------------------------------------------- For IBM-MAIN subscribe / signoff / archive access instructions, send email to [EMAIL PROTECTED] with the message: GET IBM-MAIN INFO Search the archives at http://bama.ua.edu/archives/ibm-main.html

