Thanks very much for all the help, your advice worked a treat.
One final question, originally I was defining the struct inside
the main loop and it was using 4 bytes per field rather than 2
bits, e.g.:
import std.bitmanip;
import std.stdio;
struct Crumb1
{
mixin(bitfields!(
On Monday, 31 August 2015 at 18:00:54 UTC, Andrew Brown wrote:
Is this correect behaviour?
Yes, the reason is because the nested struct has a hidden member
- a pointer to its stack context. This allows it to access
variables from the surrounding local scope.
It adds 8 bytes on 64 bit cuz
On Sunday, 30 August 2015 at 00:02:16 UTC, anonymous wrote:
On Saturday, 29 August 2015 at 23:34:47 UTC, Gary Willoughby
wrote:
But it might not be safe:
http://forum.dlang.org/thread/ztefzijqhwrouzlag...@forum.dlang.org
That link just takes me to this thread here again.
Here's the correct
On Saturday, 29 August 2015 at 20:15:53 UTC, Marc Schütz wrote:
Just cast to `Crumbs[]` directly:
import std.bitmanip;
import std.stdio;
import std.file;
struct Crumbs {
mixin(bitfields!(
ubyte, one, 2,
ubyte, two, 2,
ubyte,
Just cast to `Crumbs[]` directly:
import std.bitmanip;
import std.stdio;
import std.file;
struct Crumbs {
mixin(bitfields!(
ubyte, one, 2,
ubyte, two, 2,
ubyte, three, 2,
ubyte, four, 2
));
}
void
On Saturday, 29 August 2015 at 21:50:12 UTC, Mike James wrote:
On Saturday, 29 August 2015 at 20:15:53 UTC, Marc Schütz wrote:
Just cast to `Crumbs[]` directly:
import std.bitmanip;
import std.stdio;
import std.file;
struct Crumbs {
mixin(bitfields!(
ubyte,
On Saturday, 29 August 2015 at 23:34:47 UTC, Gary Willoughby
wrote:
But it might not be safe:
http://forum.dlang.org/thread/ztefzijqhwrouzlag...@forum.dlang.org
That link just takes me to this thread here again.
On Thursday, 27 August 2015 at 12:40:07 UTC, Mike James wrote:
How about...
A lot nicer. :)
On Thursday, 27 August 2015 at 09:00:02 UTC, Andrew Brown wrote:
Hi,
I need to read a binary file, and then process it two bits at a
time. But I'm a little stuck on the first step. So far I have:
import std.file;
import std.stdio;
void main(){
auto f = std.file.read(binaryfile);
auto g
On Thursday, 27 August 2015 at 09:26:55 UTC, rumbu wrote:
On Thursday, 27 August 2015 at 09:00:02 UTC, Andrew Brown wrote:
Hi,
I need to read a binary file, and then process it two bits at
a time. But I'm a little stuck on the first step. So far I
have:
import std.file;
import std.stdio;
On Thursday, 27 August 2015 at 09:38:52 UTC, Andrew Brown wrote:
That's lovely, thank you. One quick question, the length of the
file is not a multiple of the length of ubyte, but the cast
still seems to work. Do you know how it converts a truncated
final section?
Thanks again
Andrew
On Thursday, 27 August 2015 at 09:38:52 UTC, Andrew Brown wrote:
On Thursday, 27 August 2015 at 09:26:55 UTC, rumbu wrote:
On Thursday, 27 August 2015 at 09:00:02 UTC, Andrew Brown
wrote:
Hi,
I need to read a binary file, and then process it two bits at
a time. But I'm a little stuck on the
On 27/08/15 9:00 PM, Andrew Brown wrote:
Hi,
I need to read a binary file, and then process it two bits at a time.
But I'm a little stuck on the first step. So far I have:
import std.file;
import std.stdio;
void main(){
auto f = std.file.read(binaryfile);
auto g = cast(bool[])f;
On Thursday, 27 August 2015 at 09:00:02 UTC, Andrew Brown wrote:
Hi,
I need to read a binary file, and then process it two bits at a
time. But I'm a little stuck on the first step. So far I have:
import std.file;
import std.stdio;
void main(){
auto f = std.file.read(binaryfile);
auto g
Hi,
I need to read a binary file, and then process it two bits at a
time. But I'm a little stuck on the first step. So far I have:
import std.file;
import std.stdio;
void main(){
auto f = std.file.read(binaryfile);
auto g = cast(bool[]) f;
writeln(g);
}
but all the values of g then
15 matches
Mail list logo