Feature - Implemented bitwise operators

Fluxxdog

Active member
No, it means it can end, bor. Not that it's over. And Godwin's law is actually (not a direct quote) "as an internet discussion approaches infinity, the probability of 'Hitler' being mentioned equals 1." </trout>
And by code standards, this is getting in to a big debate about whether it should follow this standard or another. I've seen it so many times before and it gets ugly. It always seems to turn in an internet version of a religious war where nobody wins. I've seen good projects abandoned because of it. I'm saying this FReq should be kept to a FReq and the philosophical implications of using bitwise operators in ASH should be moved to Scripting Discussion where it belongs. The FReq response is based on importance, ability, and time available.
And for clarity, this is directed at bor, because when they say "if they get the time" they mean if. Pushing the issue won't help... unless you can sumbit a patch for testing, you'll have to wait.
 
Last edited:
I understand that the dev team is severely limited in both manpower and time, that was never something I overlooked. I had pretty much already given up on getting this included, unless Theraze or Veracity get -really- bored some day.
And I understand Godwin's Law. A lot of forums put a rule in place (though whether said rule gets followed is another matter) such that once a thread meets the condition, it ends immediately. That was the reference I was intending to make (and jokingly at that).
 

Fluxxdog

Active member
The way you were wording replies were "courteously rude" in that you challenge others while trying to circumvent what people might slap as traditional trolling.
bordemstirs said:
If you would care to illustrate the "state of art of computer language design" that would be wonderful, since the way it's written I don't understand at all what it is you are trying to say, other than the inferred stab at my knowledge in the subject.
If you were honestly being polite about the matter, I apologize, but you need to be more careful in what you write. "I don't understand" was the only part of that that comes off as honest, but everything else makes it read "I don't understand since you have a slightly grill weasel in your mouth."
Otherwise, drop it and carry on elsewhere.
 

Veracity

Developer
Staff member
It's not a "code standards" issue. My opinion:

I have no problem with &, |, ^, and ~ being arithmetic and, or, xor, and not. They will work however they work on your native system. Big or Little endian is not an issue for that use. The only issue comes when you want to export the data - via map-to-file, say - and import it on a system with different architecture. If you do that, word length - 32, 64, whatever - becomes an issue, and so does endianness.

That's an issue with map-to-file and file-to-map - or perhaps providing a way to convert between host byte order and "standard" byte order. Writing an integer by converting binary to decimal and reading it by converting decimal to binary works fine to ignore endianness. The issue only arises when you use these logical operators to construct integers out of bits.

That problem is orthogonal to providing arithmetic bit operators in ASH - which, as I said, would take me two or three hours of work, tops.

Edit: I code Network Protocols for a living. Trust me. I understand this! :)
 
Last edited:
Would endianness really affect filed maps? Mafia stores that data in a string representation, so I think that is averted in that case as well. Bit operations on different achitectures from the same script though might behave wonky, I'll have to look into that.

And to flux, yes, there is some bite to what I type, but I mean every word I say. The sentence to which I was referring in the quote you used pretty much made no sense to me, other than what I already said I understand.
 
Okay, so after looking at it it seems that endianness wouldn't affect &, ^, |, and ~ (unless you were doing it in some crazy way I can't imagine) because if the test data switched endianness then so would the bitmask, and the operation would still pull off without a hitch. SHL and SHR might behave oddly in a different-endianed environment, though I think that is rigged software-wise to behave as x2 and /2 regardless of endianness.
 

xKiv

Active member
Okay, so after looking at it it seems that endianness wouldn't affect &, ^, |, and ~ (unless you were doing it in some crazy way I can't imagine) because if the test data switched endianness then so would the bitmask, and the operation would still pull off without a hitch.

Only if both operands have the same bit-width (which they generally will in this case - ASH has only one integer type, right? Also, operands usually first get promoted to a common width, even in C ...).

(in-memory representation here, from lowest address on the left:)
0x1234 & 0x0f == 0x04 on one architecture becomes
0x4321 & 0xf0 == 0x20 on the other (which isn't the same thing even after toggling the endianness)
 
I'm fairly certain the int, and only int, in mafia -is- a long one.

And as for your lovely math, kKiv, In the second scenario, the 0xf0 would actually become 0xf000, making the final result backwards from the first (and therefore equivalent).
In all reality though, the second set should be
0x3412 & 0x0f00
At least in my experience.
[of course, all this data assumes that the two integers being tested are first cast to the same size]
 

Theraze

Active member
In Windows at least, floats are limited to int length...
> ash int test = 10^350;

Returned: 2147483647

> ash float test = 10^350;

Returned: 2.14748365E9

So if on other operating systems, the float properly returns the max it should be of 2^128, or roughly 3.4028236692093846346337460743177e+38, then floats will be problematic between OS implementations. The 'proper' definition was set by IEEE 754-2008, if anyone cares... http://babbage.cs.qc.cuny.edu/IEEE-754/References.xhtml has some info on it.
 

Theraze

Active member
Apparently it's failing even that... A single is what I listed as my expectation... there should be E38 if it was a single, and over 300 if it were a double... as it's returning 9, that's still staying int instead of float. In Windows, at least.
 
Returned: 2147483647

By definition that is a long int. Java might use "long" to denote something longer, but that is the highest value for a signed long int.

Can't say for sure anything about Java/ASH floats though.

Edit: I suppose it's system dependent. Don't want to sound totally douche-y. That's the long I'm used to [and that I was referring to when I first said it is one].
 
Last edited:

Theraze

Active member
Signed long int in a 32 bit compiler, or a 64 bit compiler? In a 64-bit compiler, you're looking at 9.2 quintillion instead of the 2.1 billion you're used to... signed long int in 32 bit compiler = max of ((2^31)-1). In the 64-bit compiler, you'd have ((2^63)-1).
As I said... it varies wildly, based on the system compiling it...

And a single float isn't supposed to be limited to int. Supposed to be (2^(2^7)) for a single float.
 

xKiv

Active member
I'm fairly certain the int, and only int, in mafia -is- a long one.

And as for your lovely math, kKiv, In the second scenario, the 0xf0 would actually become 0xf000, making the final result backwards from the first (and therefore equivalent).
In all reality though, the second set should be
0x3412 & 0x0f00
At least in my experience.
[of course, all this data assumes that the two integers being tested are first cast to the same size]

You *might* note that I actually already accounted for all that in the post ...
 
Bit wise operators would be perfect for this. As in most forums they use Bitwise type permission systems...

For example

there are constants named by each permission

perm_allowpost = 1;
perm_allowmod = 2;
perm_allowcomment = 4;


ehh know what its too much for me to type right now. but if you look it up in wikipedia you will see its very very usefull.
 
Top