Re: Primality test function doesn't work on large numbers?

2017-01-08 Thread Eugene Wissner via Digitalmars-d-learn
On Sunday, 8 January 2017 at 07:52:33 UTC, Elronnd wrote: I'm working on writing an RSA implementation, but I've run into a roadblock generating primes. With a more than 9 bits, my program either hangs for a long time (utilizing %100 CPU!) or returns a composite number. With 9 or fewer bits,

Re: opOpAssign on object properties

2017-01-08 Thread Ivan Kazmenko via Digitalmars-d-learn
On Sunday, 8 January 2017 at 09:22:12 UTC, collerblade wrote: How can i do opOpAssign with properties?? 1. If you want the member variable to change, naturally, you should provide a getter property which returns a reference to that variable: ref Point location() @property {

opOpAssign on object properties

2017-01-08 Thread collerblade via Digitalmars-d-learn
hello guys, i would like to have properties with /= *= += -= operators. My code: struct Point { float x=0,y=0; this(float _x, float _y) { x=_x; y=_y; } //opassign for + //opopassign for += void opOpAssign(string op=="+")(in Point p) { x+=p.x; y+=p.y; } } class

Re: CTFE difference between dmd and ldc2

2017-01-08 Thread Joseph Rushton Wakeling via Digitalmars-d-learn
On Saturday, 7 January 2017 at 22:55:55 UTC, Joseph Rushton Wakeling wrote: I should probably also create a formal issue for this. Any thoughts on how best to break it down into a minimal example? It does not appear easy to do so at first glance :-\ Turned out to be easier than I

Mixin in Inline Assembly

2017-01-08 Thread Chris M. via Digitalmars-d-learn
Right now I'm working on a project where I'm implementing a VM in D. I'm on the rotate instructions, and realized I could *almost* abstract the ror and rol instructions with the following function private void rot(string ins)(int *op1, int op2) { int tmp = *op1; asm { mov

Re: Mixin in Inline Assembly

2017-01-08 Thread Stefan Koch via Digitalmars-d-learn
On Monday, 9 January 2017 at 02:31:42 UTC, Chris M. wrote: Right now I'm working on a project where I'm implementing a VM in D. I'm on the rotate instructions, and realized I could *almost* abstract the ror and rol instructions with the following function private void rot(string ins)(int

Re: Mixin in Inline Assembly

2017-01-08 Thread Chris M. via Digitalmars-d-learn
On Monday, 9 January 2017 at 02:38:01 UTC, Stefan Koch wrote: On Monday, 9 January 2017 at 02:31:42 UTC, Chris M. wrote: [...] Yes make the whole inline asm a mixin. Awesome, got it working. Thanks to both replies.

Re: Mixin in Inline Assembly

2017-01-08 Thread Adam D. Ruppe via Digitalmars-d-learn
On Monday, 9 January 2017 at 02:31:42 UTC, Chris M. wrote: asm { mov EAX, tmp; // I'd also like to know if I could just load *op1 directly into EAX mov ECX, op2[EBP]; mixin(ins ~ " EAX, CL;"); // Issue here mov tmp, EAX; } *op1 = tmp; } However,

Re: Android Status

2017-01-08 Thread Ignacious via Digitalmars-d-learn
Yeah, not a good idea to build from source yourself. Try the advice here, ie see if you can install a package with that library or just symlink to the older library if not: http://askubuntu.com/questions/771047/erlang-error-while-loading-shared-libraries-libncursesw-so-6 Well, the only

Re: Android Status

2017-01-08 Thread Joakim via Digitalmars-d-learn
On Sunday, 8 January 2017 at 19:58:06 UTC, Ignacious wrote: I suppose it will be easier to install a real ubuntu distro rather than relying on windows? All these issues seem to be related to outdated versions? Distributor ID: Ubuntu Description:Ubuntu 14.04.5 LTS Release:14.04

Getch() Problem: C vs D

2017-01-08 Thread LouisHK via Digitalmars-d-learn
Hello, I minimize the problem to identify the problem: Here the C version: #include int main(){ int c; while(c != 27){ printf("%d\n", (c = getch())); } return 0; } And works fine, but the D version below nothing happens when I hit ESCAPE: import std.stdio; extern (C) int

Re: opOpAssign on object properties

2017-01-08 Thread Ivan Kazmenko via Digitalmars-d-learn
On Sunday, 8 January 2017 at 18:23:34 UTC, collerblade wrote: On Sunday, 8 January 2017 at 10:03:50 UTC, Ivan Kazmenko wrote: On Sunday, 8 January 2017 at 09:22:12 UTC, collerblade wrote: [...] 1. If you want the member variable to change, naturally, you should provide a getter property

Re: opOpAssign on object properties

2017-01-08 Thread collerblade via Digitalmars-d-learn
On Sunday, 8 January 2017 at 10:03:50 UTC, Ivan Kazmenko wrote: On Sunday, 8 January 2017 at 09:22:12 UTC, collerblade wrote: [...] 1. If you want the member variable to change, naturally, you should provide a getter property which returns a reference to that variable: [...] yes i tried

Re: Android Status

2017-01-08 Thread Ignacious via Digitalmars-d-learn
On Sunday, 8 January 2017 at 20:34:21 UTC, Joakim wrote: On Sunday, 8 January 2017 at 19:58:06 UTC, Ignacious wrote: I suppose it will be easier to install a real ubuntu distro rather than relying on windows? All these issues seem to be related to outdated versions? Distributor ID: Ubuntu

Need some help understanding PyD

2017-01-08 Thread Saurabh Das via Digitalmars-d-learn
I've been giving PyD a try. It's really nice and mostly everything works out of the box. I'm trying to use TensorFlow in D via Pytho, so I need to call Python functions in D. When I try to do: auto context = new InterpContext(); context.py_stmts("import tensorflow"); I get this

Re: Need some help understanding PyD

2017-01-08 Thread Saurabh Das via Digitalmars-d-learn
PS: Noticed something off. My python installation is 3.4.3: Python 3.4.3 (default, Sep 14 2016, 12:36:27) [GCC 4.8.4] on linux However when I run: context.py_stmts("import sys"); context.py_stmts("print(sys.version)"); I get: 3.4.0 (default, Apr 11 2014, 13:08:40) [GCC 4.8.2] Also,

Re: Android Status

2017-01-08 Thread Joakim via Digitalmars-d-learn
On Sunday, 8 January 2017 at 21:52:01 UTC, Ignacious wrote: Not sure what is going on, of course ;) So much BS just to do something that is suppose to be simple ;) test.d void main() { } here is test.o http://pastebin.com/NRrKgKtb Any ideas? Oh, that's easy: install the NDK too, as

Re: Primality test function doesn't work on large numbers?

2017-01-08 Thread Timon Gehr via Digitalmars-d-learn
On 08.01.2017 08:52, Elronnd wrote: I'm working on writing an RSA implementation, but I've run into a roadblock generating primes. With a more than 9 bits, my program either hangs for a long time (utilizing %100 CPU!) or returns a composite number. With 9 or fewer bits, I get primes, but I

Re: Android Status

2017-01-08 Thread Ignacious via Digitalmars-d-learn
On Sunday, 8 January 2017 at 22:19:31 UTC, Joakim wrote: On Sunday, 8 January 2017 at 21:52:01 UTC, Ignacious wrote: Not sure what is going on, of course ;) So much BS just to do something that is suppose to be simple ;) test.d void main() { } here is test.o

Re: Getch() Problem: C vs D

2017-01-08 Thread Era Scarecrow via Digitalmars-d-learn
On Sunday, 8 January 2017 at 21:19:15 UTC, LouisHK wrote: And works fine, but the D version below nothing happens when I hit ESCAPE: Is this a bug or there is another approach? Could this be because of maybe somehow it handles the console input? Kinda like how shift and different keys are

Re: opOpAssign on object properties

2017-01-08 Thread collerblade via Digitalmars-d-learn
On Sunday, 8 January 2017 at 21:50:12 UTC, Ivan Kazmenko wrote: On Sunday, 8 January 2017 at 18:23:34 UTC, collerblade wrote: [...] Hmm, right. The setter is not called, and it's by the spec. Which says that "a op= b" is rewritten as "a.opOpAssign !(op) (b)". Here: