On Tuesday, 15 July 2014 at 14:05:14 UTC, Alexandre wrote:
Strange..., why '@' ?
because x"40" == "@"
On Tuesday, 15 July 2014 at 12:24:48 UTC, Alexandre wrote:
Thanks, but, when I convert I recive a 'c' in the front of my
number...
uint reverseBytes(uint val)
{
import core.bitop : bitswap;
return bitswap(val);
}
You confused bswap with bitswap.
The former reverses bytes, the
Strange..., why '@' ?
PS: Ali Çehreli, thanks for your book, your book is wonderful!!!
On Tuesday, 15 July 2014 at 13:49:51 UTC, Ali Çehreli wrote:
On 07/15/2014 04:56 AM, Alexandre wrote:
> retVal = to!int(val);
> std.conv.ConvException@C:\D\dmd2\src\phobos\std\conv.d(1968):
Unexpec
On 07/15/2014 04:56 AM, Alexandre wrote:
> retVal = to!int(val);
> std.conv.ConvException@C:\D\dmd2\src\phobos\std\conv.d(1968): Unexpected
> '@' when converting from type string to type int
That means to!int failed because 'val' contained a '@' character in it:
import std.conv;
void
Something is wrong between our communication...
I am wanting to do something better to order the bytes, for this
my code...
https://gist.github.com/bencz/3576dfc8a217a34c05a9
For example, in that case:
injectData(image[0x207], x"30204000");
It's more simple to use something like:
injectData(i
Alexandre:
Thanks, but, when I convert I recive a 'c' in the front of my
number...
This shows it inverts all bits, not just the four byte positions.
I don't understand:
import core.bitop: bitswap;
uint reverseBytes(in uint val) pure nothrow @safe @nogc {
return val.bitswap;
}
void ma
Thanks, but, when I convert I recive a 'c' in the front of my
number...
uint reverseBytes(uint val)
{
import core.bitop : bitswap;
return bitswap(val);
}
//...
writefln("%x", reverseBytes(0x00402030));
//...
// output: c040200
On Tuesday, 15 July 2014 at 12:16:26 UTC, bearoph
Alexandre:
return (retVal & 0x00FF) << 24 |
(retVal & 0xFF00) << 8 |
(retVal & 0x00FF) >> 8 |
(retVal & 0xFF00) >> 24;
See also core.bitop.bswap.
Bye,
bearophile