Search found 128 matches

by Ledigimate
Thu Dec 20, 2018 3:48 pm
Forum: Talking LiveCode
Topic: Circular shift
Replies: 20
Views: 775

Re: Circular shift

Sadly 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...
by Ledigimate
Thu Dec 20, 2018 1:35 pm
Forum: Talking LiveCode
Topic: baseConvert woes
Replies: 5
Views: 221

Re: baseConvert woes

What does the number represent? Is it an actual quantity, or a decimal representation of byte values? If the latter, the binaryEncode and binaryDecode functions may help, since they can operate on a series of values in one pass, with lots of conversion options. Kind of both. The number is an actual...
by Ledigimate
Wed Dec 19, 2018 8:40 pm
Forum: Talking LiveCode
Topic: baseConvert woes
Replies: 5
Views: 221

Re: baseConvert woes

Never mind.

I see the dictionary says baseConvert can only handle numbers between zero and 4,294,967,295 (2^32 - 1).
The number 7909090520 is thus too large for baseConvert to handle. I guess I'll have to write my own function to convert larger numbers!

Gerrie
by Ledigimate
Wed Dec 19, 2018 8:24 pm
Forum: Talking LiveCode
Topic: baseConvert woes
Replies: 5
Views: 221

baseConvert woes

Dear forum The baseConvert function tells me that the numbers 3614123224 and 7909090520 has the same binary representation! WHY?? put baseConvert("3614123224", 10, 2) is baseConvert("7909090520", 10, 2) -- yields true This has been causing me huge frustration. Can someone explain what's going on her...
by Ledigimate
Tue Dec 18, 2018 12:30 am
Forum: Talking LiveCode
Topic: Circular shift
Replies: 20
Views: 775

Re: Circular shift

Oh, sorry. No default bash or ksh on Windows. But did you already try do as "vbscript"? if the platform is "Win32" then do "result = 2 << 4" as "vbscript" put the result else ... end if See https://docs.microsoft.com/en-us/dotnet/visual-basic/language-reference/operators/left-shift-operator and htt...
by Ledigimate
Mon Dec 17, 2018 8:07 pm
Forum: Talking LiveCode
Topic: Circular shift
Replies: 20
Views: 775

Re: Circular shift

[-hh] wrote:
Mon Dec 17, 2018 7:47 pm
Gerrie.

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))")
There piping is also available.
It gives me "<< was unexpected at this time." on my system (Win 10 Pro).
by Ledigimate
Mon Dec 17, 2018 6:42 pm
Forum: Talking LiveCode
Topic: Circular shift
Replies: 20
Views: 775

Re: Circular shift

As you are comparing your pure LC Script solution to the 32bit C operators: The browser widget belongs to LC, so we have, besides *2^pPosition and div 2^pPosition, also the following possibility. function rotateBits pN, pP, pD -- 32bit numbers only if pD is "L" then put "<<" into op -- signed left ...
by Ledigimate
Mon Dec 17, 2018 8:54 am
Forum: Talking LiveCode
Topic: Circular shift
Replies: 20
Views: 775

Re: Circular shift

Here's what I've got working. function rotateBits pNumber, pBitLength, pPositions, pDirection local tBase2, tBase2new, tNumLeadingBits put baseConvert(pNumber, 10, 2) into tBase2 put pBitLength - length(tBase2) into tNumLeadingBits repeat tNumLeadingBits times put "0" before tBase2 end repeat if pDi...
by Ledigimate
Mon Dec 17, 2018 6:22 am
Forum: Talking LiveCode
Topic: Circular shift
Replies: 20
Views: 775

Re: Circular shift

So typically, does a base 2 rotation ignore "leading" zeros? I don't know, I haven't done it before in any programming language. If I wanted three eggs over easy, I might order "0003" eggs, and if the waiter either had a sense of humor or understood the math I was foisting on him, I would get an ea...
by Ledigimate
Sun Dec 16, 2018 10:54 pm
Forum: Talking LiveCode
Topic: Circular shift
Replies: 20
Views: 775

Re: Circular shift

Ah. But still not getting it. Rotating the base 2 value of "1234" ("10011010010") gives "00110100101" which in base 10 is 421.Or if you rotate the other way, 617. In order to get 2468 from 1234 (double the value), you must double the base 2 string, which requires that you add a "0" to the right sid...
by Ledigimate
Sun Dec 16, 2018 9:42 pm
Forum: Talking LiveCode
Topic: Circular shift
Replies: 20
Views: 775

Re: Circular shift

Hi. Hermann will soon jump all over this. But before he does, please explain how you get 4644 from 1234. Changing those values to base 2, and then rotating, does not do that, so i am on the wrong track. Craig Sorry, my bad!! :oops: I used a programmers' calculator to manually do the bit rotation an...
by Ledigimate
Sun Dec 16, 2018 9:33 pm
Forum: Talking LiveCode
Topic: [Solved] md5digest of large files, how reliable is it?
Replies: 21
Views: 811

Re: [Solved] md5digest of large files, how reliable is it?

Maybe not - did you see Trevor's post on this? By reading the file in chunks and aggregating the checksum you can get a good result without taxing RAM: https://forums.livecode.com/viewtopic.php?f=9&t=31892#p174152 The only downside to that approach would be if you later need to compare the checksum...
by Ledigimate
Sun Dec 16, 2018 8:39 pm
Forum: Talking LiveCode
Topic: Circular shift
Replies: 20
Views: 775

Re: Circular shift

Hello Craig

Yes I want to do something like that, only it needs to be a bitwise rotation of the individual bits of a 32-bit register, e.g. the number 1234 becomes the number 4644 if you rotate the bits left by 1 position.

edit: sorry, my example is 12-bit integer, not a 32-bit integer
by Ledigimate
Sun Dec 16, 2018 7:08 pm
Forum: Talking LiveCode
Topic: Circular shift
Replies: 20
Views: 775

Circular shift

Hi I'm looking for a way to perform circular shift operations in LiveCode, like can be done in the C language using the bitwise operators << and >>. I could find only these four bitwise operators in the LC dictionary: bitAnd, bitOr, bitXor, and bitNot. Can someone point me in the right direction? Ge...
by Ledigimate
Sat Dec 15, 2018 2:04 pm
Forum: Talking LiveCode
Topic: [Solved] md5digest of large files, how reliable is it?
Replies: 21
Views: 811

Re: [Solved] md5digest of large files, how reliable is it?

From the dictionary entry to messageDigest , introduced in LC 9: MD5 is cryptographically broken and unsuitable for further use. Do not use for security-critical purposes, unless required for backward compatibility with existing systems. Thank you, Hermann. I only needed it for checksum purposes.

Go to advanced search