Re: create and initialise array

2020-09-19 Thread Mike Parker via Digitalmars-d-learn
On Saturday, 19 September 2020 at 21:53:34 UTC, mw wrote: On Thursday, 20 June 2019 at 07:57:25 UTC, KnightMare wrote: imo NaN is useless, weird and unusual coz integrals and pointers are "all bits zeroes" but float and chars are "all bits ones". WTF? its strange that bool.init is false in

Re: create and initialise array

2020-09-19 Thread mw via Digitalmars-d-learn
On Thursday, 20 June 2019 at 07:57:25 UTC, KnightMare wrote: On Thursday, 20 June 2019 at 01:32:04 UTC, matheus wrote: import std.stdio; import std.array; void main(){ auto s = uninitializedArray!(float[])(100); s[] = 0.0f; writeln(s[0]); } Even with this, user has to write two

Re: create and initialise array

2019-06-20 Thread Alex via Digitalmars-d-learn
Thanks Matheus, thats what i needed. I added a PR to mention this function in the language documentation about arrays.

Re: create and initialise array

2019-06-20 Thread KnightMare via Digitalmars-d-learn
On Thursday, 20 June 2019 at 01:32:04 UTC, matheus wrote: import std.stdio; import std.array; void main(){ auto s = uninitializedArray!(float[])(100); s[] = 0.0f; writeln(s[0]); } another version: auto arr = new double[ 10 ]; writeln( arr[5] ); // NaN arr.length += 10; writeln(

Re: create and initialise array

2019-06-19 Thread matheus via Digitalmars-d-learn
On Thursday, 20 June 2019 at 01:06:09 UTC, Alex wrote: Is there a way of creating and initialising a dynamic array ? for example I am doing this: auto arr = new float[]; arr[] = 0.0f; Profiling indicates that the compiler (gdc) is spending significant time memsetting the whole array to

create and initialise array

2019-06-19 Thread Alex via Digitalmars-d-learn
Is there a way of creating and initialising a dynamic array ? for example I am doing this: auto arr = new float[]; arr[] = 0.0f; Profiling indicates that the compiler (gdc) is spending significant time memsetting the whole array to something (nan ?) before I immediately memset it to 0.0f.