Monkey Programming/Unsigned Shift Right

'Shift Operations - Left, Right or Unsigned Right Shift' tutorial was cited in a Monkey Programming Forum post in 2012.

The Shift Operations - Left, Right or Unsigned Right Shift tutorial was cited in a Monkey Programming Forum post in 2012.

Subject:  Monkey Programming/Unsigned Shift Right
Date: Jun 6, 2012
Author: therevills
Source: http://www.monkeycoder.co.nz/Community/posts.php?topic=3005

Ahh... looks like we have a small bug in MonkeyMax then :P

BlitzMax:
Local a:Int = -858993460 ' binary: 11001100110011001100110011001100
Local o1:Int = a Shl 6 ' left shift
Local o2:Int = a Shr 6 ' unsigned right shift
Local o3:Int = a Sar 6 ' signed right shift
Print ("a   = "+a)
Print ("ol1 = "+o1)
Print ("ol2 = "+o2)
Print ("ol3 = "+o3)

Outputs:
a   = -858993460
ol1 = 858993408
ol2 = 53687091
ol3 = -13421773

Monkey:
Function Main()
  Local a:Int = -858993460 ' binary: 11001100110011001100110011001100
  Local o1:Int = a Shl 6 ' left shift
  Local o2:Int = a Shr 6 ' signed right shift
  'Local o3:Int = a Sar 6 ' signed right shift
  Print ("a   = "+a)
  Print ("ol1 = "+o1)
  Print ("ol2 = "+o2)
  'Print ("ol3 = "+o3)
End

Outputs
a   = -858993460
ol1 = 858993408
ol2 = -13421773

I converted this Java example:
https://www.herongyang.com/Java/Byte-Data-Type-Shift-Operations.html

/**
 * ShiftOperations.java
 * Copyright (c) 2006 by Dr. Herong Yang, https://www.herongyang.com/
 */
public class ShiftOperations {
   public static void main(String[] arg) {
      int a = -858993460; // binary: 11001100110011001100110011001100

      int o1 = a << 6;  // left shift
      int o2 = a >> 6;  // right shift
      int o3 = a >>> 6; // unsigned right shift
...

Table of Contents

 About This Book

 Reference Citations in 2023

 Reference Citations in 2022

 Reference Citations in 2021

 Reference Citations in 2020

 Reference Citations in 2019

 Reference Citations in 2018

 Reference Citations in 2017

 Reference Citations in 2016

 Reference Citations in 2015

 Reference Citations in 2014

 Reference Citations in 2013

Reference Citations in 2012

 bikin website dalam bahasa cina dengan php

 72 sekunde kao 72 godine

 nsIConverterOutputStream handling GB2312 characters

 AbstractMethodError while calling PreparedStatement.setBinaryStream()

 how to invoke web service without generating a client

 Sample program to test SSL Connection with certicates

 How to know KeyManager given a keystore

 once again: classpath and ojdbc14.jar

 12c... webtier up, Oracle managment server down

 Problems with class not found exception

 Spring Projects > Roo > Issue with Chinese characters

Monkey Programming/Unsigned Shift Right

 Unable to get issuer certificate

 How to convert keystore (from native android project) to .p12 to use with AIR project?

 Installing JDBC drivers ojdbc14.jar

 Quickly view the threads of your blocked Ruby application with JStack

 android verify signature of file with .der public key

 Unable to install updates KB2770917 and KB2779768

 Reference Citations in 2011

 Reference Citations in 2010

 Reference Citations in 2009

 Reference Citations in 2008

 Reference Citations in 2007

 Reference Citations in 2006

 Reference Citations in 2005

 Reference Citations in 2004

 Reference Citations in 2003