Unexpected results when casting dword to byte [4] (endianity swap?)
Im trying to cast a dword into an array of 4 bytes. When i do this, the
bytes seem to flip around (change endianness)
As i understand it a dword equaling 0x11223344 on little endian systems
will look like this:
0000_1011___0001_0110___0010_0001____0010_1100
but when i do this:
typedef unsigned long dword;
typedef unsigned char byte;
int main(void)
{
dword a = 0x11223344;
byte b[4];
memcpy(b, &a, 4);
printf("%x %x %x %x\n", b[0], b[1], b[2], b[3]);
}
I get 44 33 22 11.
I expected it to be 11 22 33 44.
The same thing happens when i use reinterpret_cast or
union
{
dword a;
byte b[4];
} foo;
Im guessing Im wrong and not the compiler/processor, but what am i missing
here? Also how would this look on a big endian system?
Friday, 23 August 2013
Sending information to a library
Sending information to a library
I'm working with OSMF, the StrobeMediaPlayback and FlashBuilder/Eclipse.
I have a variable that I've captured from a flashvar, and stored in a
singleton class. I want it to be accessible to another package that I'm
using as a library for this project.
I can't import the class directly, because it would cause a cycle, nor can
I seem to access it with a static reference, because it's in a different
package.
How can I do this?
Here's what I want to send:
StrobeMediaPlayback > src > SessionFlashVars.as
Here's where I want to send it:
OSMF > org.osmf > net > NetNegotiator.as
I'm working with OSMF, the StrobeMediaPlayback and FlashBuilder/Eclipse.
I have a variable that I've captured from a flashvar, and stored in a
singleton class. I want it to be accessible to another package that I'm
using as a library for this project.
I can't import the class directly, because it would cause a cycle, nor can
I seem to access it with a static reference, because it's in a different
package.
How can I do this?
Here's what I want to send:
StrobeMediaPlayback > src > SessionFlashVars.as
Here's where I want to send it:
OSMF > org.osmf > net > NetNegotiator.as
Expense and Balance Mismatch
Expense and Balance Mismatch
I searched and couldn't find a post in stack exchange for this. I recently
saw a calculation for rupee spend and having balance in yahoo, but i am
not quiet convinced with the answer given...
the question goes like this....
If i have 50 Rupees
Spend -- Balance
0---------50
20--------30
15--------15
9---------6
6---------0
If we see the sum of amount spend it gives 50 Rupees.
But if we calculate the balance amount (30+15+6) it gives 51 rupee instead
of 50 rupees.
How could this be possible....
If this question is mentioned somewhere else in this forum please refer
that too...
I searched and couldn't find a post in stack exchange for this. I recently
saw a calculation for rupee spend and having balance in yahoo, but i am
not quiet convinced with the answer given...
the question goes like this....
If i have 50 Rupees
Spend -- Balance
0---------50
20--------30
15--------15
9---------6
6---------0
If we see the sum of amount spend it gives 50 Rupees.
But if we calculate the balance amount (30+15+6) it gives 51 rupee instead
of 50 rupees.
How could this be possible....
If this question is mentioned somewhere else in this forum please refer
that too...
Wish + tense agreement + subordinate clause
Wish + tense agreement + subordinate clause
I wish I knew what he did/does for a living
I wish I knew what he had/has bought her
I wish I knew what he would/will do in this case
I wish I'd known what he had done for a living
I wish I'd known what he did for a living
I wish I'd known what he would do in this case
Are they correct and what the situations are like when hear them?
I wish I knew what he did/does for a living
I wish I knew what he had/has bought her
I wish I knew what he would/will do in this case
I wish I'd known what he had done for a living
I wish I'd known what he did for a living
I wish I'd known what he would do in this case
Are they correct and what the situations are like when hear them?
Thursday, 22 August 2013
Mongodb Emulator to simulate real nosql transactions
Mongodb Emulator to simulate real nosql transactions
I'm trying to develop and application a "database builder" or a designer
that will enable the users to experiment on using mongodb as well as
produce them json databases.
Question is:
I wanted to do this because of I am afraid that the users of the
application will have actual interaction on the database and let them do
what they want, am I right on this one, is providing the user real mongodb
interaction will have security risk?
Are there javascript libraries to do what I wanted?
I'm trying to develop and application a "database builder" or a designer
that will enable the users to experiment on using mongodb as well as
produce them json databases.
Question is:
I wanted to do this because of I am afraid that the users of the
application will have actual interaction on the database and let them do
what they want, am I right on this one, is providing the user real mongodb
interaction will have security risk?
Are there javascript libraries to do what I wanted?
Ruby: Can I get an instance by its ID?
Ruby: Can I get an instance by its ID?
In Ruby, if I have the ID of an object instance as a string, such as
"#<Meeting:0x4531860>", can I get the instance its self by this ID?
# what I want
meeting = SOME_MAGIC_HERE "#<Meeting:0x4531860>"
# and then I can handle the meeting itself
meeting.name # => 'BLABLABLA'
In Ruby, if I have the ID of an object instance as a string, such as
"#<Meeting:0x4531860>", can I get the instance its self by this ID?
# what I want
meeting = SOME_MAGIC_HERE "#<Meeting:0x4531860>"
# and then I can handle the meeting itself
meeting.name # => 'BLABLABLA'
How do I access flashvars if I can't access the stage?
How do I access flashvars if I can't access the stage?
How do I access flashvars if I can't access the stage?
I'm fiddling with the Open Source Media Framework's Strobe Media Playback
player, and I'm trying to take a flashvar and put it in the package
org.osmf.net.NetNegotiator.
But the netNegotiator class can't access the stage, so I can't do
stage.loaderInfo.parameters to get the flashvar.
Alternately, I can get the flashvar from StrobeMediaPlayback.as, but I
can't figure out how to send it over there.
I've tried to import the package in the StrobeMediaPlayback.as, but not
only does NetNegotiator show up on the predictive typing thing, I get an
undefined error when I try to use it.
How do I access flashvars if I can't access the stage?
I'm fiddling with the Open Source Media Framework's Strobe Media Playback
player, and I'm trying to take a flashvar and put it in the package
org.osmf.net.NetNegotiator.
But the netNegotiator class can't access the stage, so I can't do
stage.loaderInfo.parameters to get the flashvar.
Alternately, I can get the flashvar from StrobeMediaPlayback.as, but I
can't figure out how to send it over there.
I've tried to import the package in the StrobeMediaPlayback.as, but not
only does NetNegotiator show up on the predictive typing thing, I get an
undefined error when I try to use it.
Subscribe to:
Posts (Atom)