Thanks Josh. I kinda managed to get it working. so for the records if someone else need it, it seems to work fine.
private function safeBitCheck(num:Number,comparison:Number):Boolean { if(num < 2147483647 ) { return (num & comparison)==comparison; } else { var binNumber:String = strrev(base_convert(num,10,2)); var binComparison:String = strrev(base_convert(comparison,10,2)); for(var i:uint=0; i<binComparison.length; i++ ) { if( binNumber.length < i || (binComparison.charAt(i)==="1" && binNumber.charAt(i)==="0") ) { return false; } } return true; } } public function strrev(str:String):String { return str.split("").reverse().join(""); } public function base_convert(num:Number, frombase:Number, tobase:Number):String { return parseInt(num+'', frombase+0).toString(tobase+0); } --- In flexcoders@yahoogroups.com, Josh McDonald <dzn...@...> wrote: > > Does "result = (uint(number) & uint(comparison))" work? > > -Josh > > 2009/1/20 Rafael Faria <rafaelfaria.gru...@...> > > > > > Please, > > > > anyone with skills to convert the following php function to flex? i'm > > killing myself trying... > > > > please... anyone? > > > > thanks > > rafael > > > > ----- > > > > /** > > * Perform a float-safe bitwise AND comparison > > * > > * @param int/float $number The number to which to perform a bitwise AND > > * @param int/float $comparison The number with which to perform a > > bitwise AND > > * @return bool > > */ > > function safeBitCheck($number,$comparison) { > > if( $number < 2147483647 ) { > > return ($number & $comparison)==$comparison; > > } else { > > $binNumber = strrev(base_convert($number,10,2)); > > $binComparison = strrev(base_convert($comparison,10,2)); > > for( $i=0; $i<strlen($binComparison); $i++ ) { > > if( strlen($binNumber)<$i || ($binComparison{$i}==="1" && > > $binNumber{$i}==="0") ) { > > return false; > > } > > } > > return true; > > } > > } > > > > safeBitCheck(17,16); // true > > safeBitCheck(17,2); // false > > safeBitCheck((4294967296+8589934592),4294967296); // true > > safeBitCheck(2,8589934592); // false > > > > > > ------------------------------------ > > > > -- > > Flexcoders Mailing List > > FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt > > Alternative FAQ location: > > https://share.acrobat.com/adc/document.do?docid=942dbdc8-e469-446f-b4cf-1e62079f6847 > > Search Archives: > > http://www.mail-archive.com/flexcoders%40yahoogroups.comYahoo! Groups > > Links > > > > > > > > > > > -- > "Therefore, send not to know For whom the bell tolls. It tolls for thee." > > Like the cut of my jib? Check out my Flex blog! > > :: Josh 'G-Funk' McDonald > :: 0437 221 380 :: j...@... > :: http://flex.joshmcdonald.info/ > :: http://twitter.com/sophistifunk >