As Mark and Colin said, shift left is just multiplying by 2 however
many times, but assuming the numbers are 32 bit positive integers,
you have to get rid of anything above 2^32, so I think this does it:
function shiftLeft pNum, pSteps
if pNum = 0 then return 0
if pSteps is empty then put 1 into pSteps
put pNum * (2 ^ pSteps) into tShiftedNum
if tShiftedNum > 2 ^ 32 then subtract 2 ^ 32 from tShiftedNum
return tShiftedNum
end shiftLeft
Best,
Mark
On 29 Apr 2008, at 18:34, David Bovill wrote:
2008/4/29 Colin Holgate <[EMAIL PROTECTED]>:
At 5:23 PM +0100 4/29/08, David Bovill wrote:
Is there an equivalent in Rev - if not can anyone translate this
to some
basic math functions?
Shift left is the same as * 2. 31 << 3 would be the same as * 8.
What was it that you needed to achieve?
I'm making a start on the Map library as part of a suite of open
source API
libraries. This JavaScript function is for a Mercator Projection
used in
Google maps amongst others. The script looks like this:
function Adjust(x,y,deltaX,deltaY,z)
{
var offset=268435456;
var radius=offset/Math.PI;
function LToX(x)
{
return Math.round(offset+radius*x*Math.PI/180);
}
function LToY(y)
{
return Math.round(offset-radius*Math.log((1+Math.sin(y*Math.PI/
180))/(1-Math.sin(y*Math.PI/180)))/2);
}
function XToL(x)
{
return ((Math.round(x)-offset)/radius)*180/Math.PI;
}
function YToL(y)
{
return (Math.PI/2-2*Math.atan(Math.exp((Math.round(y)-offset)/
radius)))*180/Math.PI;
}
return {x:XToL(LToX(x)+(deltaX<<(21-z))),y:YToL(LToY(y)+(deltaY<<
(21-z)))};
}
And its the last line that looks tricky. The
deltaX<<(21-z)
is the bit I guess i am looking most to figure out?
_______________________________________________
use-revolution mailing list
[email protected]
Please visit this url to subscribe, unsubscribe and manage your
subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution
_______________________________________________
use-revolution mailing list
[email protected]
Please visit this url to subscribe, unsubscribe and manage your subscription
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution