On Friday, 17 July 2015 at 19:03:46 UTC, Jacob Carlborg wrote:
On 2015-07-17 20:58, byron wrote:
Ah I miss read, if you want as a float, not a float array you
can do:
byte[] b = [1, 2, 3, 4];
float f = *cast(float*)b.ptr;
not sure if there is a better way
I think a union can be used as wel
On Friday, 17 July 2015 at 18:53:24 UTC, byron wrote:
On Friday, 17 July 2015 at 18:43:27 UTC, DLangLearner wrote:
Excuse me for my trivial question, but I'd like to know how to
convert byte array to float? What I could think of are
cast(float)(byte[]) and to!float(byte[]) but they do not work
On Friday, 17 July 2015 at 18:43:27 UTC, DLangLearner wrote:
Excuse me for my trivial question, but I'd like to know how to
convert byte array to float? What I could think of are
cast(float)(byte[]) and to!float(byte[]) but they do not work
for me. Thanks!
You want to include [] in the cast s
On Friday, 17 July 2015 at 07:56:48 UTC, aki wrote:
On Thursday, 16 July 2015 at 09:17:47 UTC, Daniel Kozák wrote:
class DerivedThread : Thread {
shared int count = 0;
}
I thought shared is only for whole of the object.
auto thr = new DerivedThread();
Here, "thr" is not shared but it's
On Thursday, 16 July 2015 at 21:48:06 UTC, byron wrote:
On Thursday, 16 July 2015 at 07:57:13 UTC, aki wrote:
[...]
If I remember a synchronized method requires "this" to be
shared, you should be fine using a synchronized block in the
method for non-shared instances. But using atomicOp wi
On Thursday, 16 July 2015 at 07:57:13 UTC, aki wrote:
I can't resolve the compile errors:
import core.thread;
class DerivedThread : Thread {
int count = 0;
this() {
super(&run);
}
private void run() {
inc(); //testThread.d(8): Error: shared metho
On Thursday, 16 July 2015 at 21:12:05 UTC, anonymous wrote:
I have the following code, working under Win and Linux:
---
import std.process: environment;
immutable string p;
static this() {
version(Win32) p = environment.get("APPDATA");
version(linux) p = "/home/" ~ environment.get("USE
Should this work? It seems like the short circuit booleans are not
working:
import std.traits;
enum isPrimitive(T) = isBasicType!T || (isArray!T && isBasicType!
(ForeachType!T));
void main() {
assert(isPrimitive!int);
assert(isPrimitive!char);
On Sun, 08 Jun 2014 19:44:12 +, monarch_dodra wrote:
> On Sunday, 8 June 2014 at 18:28:25 UTC, Byron wrote:
>> void c_free(bar* b) { b = null; }
>
> Heads up: This code does nothing. You are passing the pointer by value,
> so "b = null;" will have no effect at the end of the call.
> Use pass
Can we not use scope(..) in a mixin template?
struct bar {}
bar* c_make() { return new bar(); }
void c_free(bar* b) { b = null; }
mixin template Foo() {
auto b = c_make;
scope(exit) if(b) c_free(b);
}
void main() {
mixin Foo;
}
I get Error: Declaration expected, not '('
-Byron
10 matches
Mail list logo