You could also try to use leftshift and rightshift of the shell, for example
Code: Select all
put shell("echo $((2 << 4)); echo $((1024 >> 3))")
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
Code: Select all
put shell("echo $((2 << 4)); echo $((1024 >> 3))")
It gives me "<< was unexpected at this time." on my system (Win 10 Pro).[-hh] wrote: ↑Mon Dec 17, 2018 7:47 pmGerrie.
You could also try to use leftshift and rightshift of the shell, for exampleThere piping is also available.Code: Select all
put shell("echo $((2 << 4)); echo $((1024 >> 3))")
Code: Select all
if the platform is "Win32" then
do "result = 2 << 4" as "vbscript"
put the result
else
...
end if
Hermann, you are my hero. The "do statementList as alternateLanguage" method is just SO much easier than using a browser widget! Why haven't we thought of that sooner?[-hh] wrote: ↑Mon Dec 17, 2018 8:43 pmOh, sorry. No default bash or ksh on Windows.
But did you already try do as "vbscript"?
See https://docs.microsoft.com/en-us/dotnet ... t-operatorCode: Select all
if the platform is "Win32" then do "result = 2 << 4" as "vbscript" put the result else ... end if
and
https://stackoverflow.com/questions/331 ... sual-basic
Just to collect all options ...
Code: Select all
function rotateBits pN, pP, pD -- 32-bit numbers only
if pD is "L" then
do "result = (" & value(pN) & " << " & value(pP) & ") | (" & value(pN) & " >>> (32 - " & value(pP) & "))" as "JavaScript"
else
do "result = (" & value(pN) & " >>> " & value(pP) & ") | (" & value(pN) & " << (32 - " & value(pP) & "))" as "JavaScript"
end if; return the result
end rotateBits
But you're still my hero.[-hh] wrote: ↑Tue Dec 18, 2018 12:48 amSadly do as "javascript" is currently available ONLY for HTML5-standalones (Emscripten).
For desktop/mobile we have to use the javascript of libbrowser (accessible via a browser widget).
And the browser widget doesn't currently work on most linux flavours.
So you have to do a platform switch or use your pure LC versions (which works everywhere).
Code: Select all
function rotateBits pNumber, pPositions, pDirection -- 32-bit numbers only
if pDirection is "right" then
return (pNumber div (2^pPositions)) bitOr ((pNumber * (2^(32 - pPositions))) bitAnd 4294967295)
else
return ((pNumber * (2^pPositions)) bitAnd 4294967295) bitOr (pNumber div (2^(32 - pPositions)))
end if
end rotateBits