ActionScript / Flex: bitwise OR / OR after 32 bits

Question: Is there a simple way (library function) to perform bitwise OR or OR for numbers larger than 32-bits in ActionScript?

From the docs: “Bitwise operators internally manipulate floating point numbers to change them to 32-bit integers. The exact operation performed depends on the operator, but all bitwise operations evaluate each binary digit (bit) of a 32-bit integer separately to calculate a new value . "

Bummer ...

I can not use and and | ops - does AS function as a library for this for numbers?

Features: I am moving a bunch of java to flex, and java supports a bunch of "long" masks. I know that I can separate Java masks into two types from the flexible side. Since all my manipulations with the mask are localized, this will not be too painful. However, I would like to keep the port as 1-1 as possible.

Any suggestions? Thanks!

+4
source share
5 answers

I think your easiest option is to break the masks and, if possible, mask the data into two parts. You are struggling with the difference in function, so you should not try to deal with it. And if you don’t need real BigNum support, it’s better not to consider it.

+1
source

If you don't mind porting some Javascript, Leemon Baird has written a Javascript library for public domains for handling large numbers here:

http://www.leemon.com/crypto/BigInt.html

You cannot explicitly use the and and | operators, but you should be able to extend existing code using the bitwiseAnd and bitwiseOr methods.

+1
source

`

public class NumberUtils { public static const MSB_CONV : Number = Math.pow(2, 32); public static function bitwiseAND(num1 : Number, num2 : Number) : Number { var msb1 : int = num1 / MSB_CONV; var msb2 : int = num2 / MSB_CONV; return (msb1 & msb2) * MSB_CONV + (num1 & num2); } ..OR..shiftRight.. } 

`

+1
source

According to http://livedocs.adobe.com/flex/3/html/help.html?content=03_Language_and_Syntax_11.html , there are no 64-bit integers (signed or unsigned) ... only 32-bit.

The type of number, as you mentioned above, has a 53-bit mantissa, which is too short for you.

I was looking for an implementation of BigNum FLEX, but could not find it.

I assume you will have to simulate this using an int array or a high and low int class.

Good luck, Randy Stigbauer

0
source
 public function readInt64():Number { var highInt:uint = bytes.readUnsignedInt(); var lowerInt:uint = bytes.readUnsignedInt(); return highInt * Math.pow(2,32) + lowerInt; } public function writeInt64(value:Number):void { this.writeUnsignedInt(int(value / 0xffffffff)); this.writeUnsignedInt(int(value)); } 
0
source

All Articles