Official Everybody Edits Forums

Do you think I could just leave this part blank and it'd be okay? We're just going to replace the whole thing with a header image anyway, right?

You are not logged in.

#1 2015-08-25 21:14:42

capasha
Member
Joined: 2015-02-21
Posts: 4,066

I need some help with bitwise (Bitmap to minimapcolor)

Here is the image, the one I read pixels from: http://i.imgur.com/R56XPhp.png
Sourcecode for C#: http://pastebin.com/WcULhNg1
Sourcode for AS3: http://pastebin.com/5Bw6s4xh

And the errors because I do something really wrong with bitwise.

Operator '<<' cannot be applied to operands of type 'double' and 'int'

return 4.27819008 | _loc2_ << 16 | _loc3_ << 8 | _loc4_ << 0;
redredred RED everywhere.

Offline

#2 2015-08-25 21:57:00

AlphaJon
Member
From: Who knows
Joined: 2015-07-21
Posts: 1,297

Re: I need some help with bitwise (Bitmap to minimapcolor)

You need both operands to be ints for << to work. You are using doubles as left operands

Offline

#3 2015-08-25 22:05:16, last edited by hummerz5 (2015-08-25 22:06:34)

hummerz5
Member
From: wait I'm not a secret mod huh
Joined: 2015-08-10
Posts: 5,853

Re: I need some help with bitwise (Bitmap to minimapcolor)

I imagine some super knowledgeable developer will either ninja me or prove me wrong, but I'm thinking there's somethign specific to AS3 notation that's giving you the issue.
4.27819008E9 (AS3)
4.27819008 (C#)

If I throw the AS3 number right into the web console, I get
4278190080
What that means, I'm not sure. Though it appears to be the decimal * 10^9 but yeah dunno

ninja edit:
Well, I still think my idea stands, but a valid point. I never could get C# to bitshift dem doubles. Why? dunno. There's probably a library out there.

Offline

#4 2015-08-25 22:16:24, last edited by AlphaJon (2015-08-25 22:21:09)

AlphaJon
Member
From: Who knows
Joined: 2015-07-21
Posts: 1,297

Re: I need some help with bitwise (Bitmap to minimapcolor)

hummerz5 wrote:

I imagine some super knowledgeable developer will either ninja me or prove me wrong, but I'm thinking there's somethign specific to AS3 notation that's giving you the issue.
4.27819008E9 (AS3)
4.27819008 (C#)

If I throw the AS3 number right into the web console, I get
4278190080
What that means, I'm not sure. Though it appears to be the decimal * 10^9 but yeah dunno

ninja edit:
Well, I still think my idea stands, but a valid point. I never could get C# to bitshift dem doubles. Why? dunno. There's probably a library out there.

Doubles are not represented like integers (see image below), so shifting them would/could cause unexpected behavior
IEEE_754_Double_Floating_Point_Format.svg
Image from wikipedia, for more information see here

Shifting it would cause both the exponent and fraction part to shift, so unless you know what is in each part, you won't know what it would produce.

Can't really help with the AS3 part though, as I have never used it, but I guess it's the same problem.

Offline

#5 2015-08-25 23:03:21

capasha
Member
Joined: 2015-02-21
Posts: 4,066

Re: I need some help with bitwise (Bitmap to minimapcolor)

Jonathan1003 wrote:

You need both operands to be ints for << to work. You are using doubles as left operands

It doesn't work if I change them to int or not. Still the same issues.

Offline

#6 2015-08-25 23:23:19

AlphaJon
Member
From: Who knows
Joined: 2015-07-21
Posts: 1,297

Re: I need some help with bitwise (Bitmap to minimapcolor)

capasha wrote:
Jonathan1003 wrote:

You need both operands to be ints for << to work. You are using doubles as left operands

It doesn't work if I change them to int or not. Still the same issues.

Operator '<<' cannot be applied to operands of type 'double' and 'int'

| also requires both operands to be int, the 4.27819008 OR-ing with the 3 other results may also cause errors
This error seems pretty explicit, are you sure there's not something else messing with the code?

Offline

#7 2015-08-26 01:22:40

hummerz5
Member
From: wait I'm not a secret mod huh
Joined: 2015-08-10
Posts: 5,853

Re: I need some help with bitwise (Bitmap to minimapcolor)

So, did we conclude that 4.984893587 is in fact not a double?

Offline

hummerz51440548560534644

Board footer

Powered by FluxBB

[ Started around 1732781488.836 - Generated in 0.044 seconds, 12 queries executed - Memory usage: 1.45 MiB (Peak: 1.57 MiB) ]