Re: Floating point values in structs.

2020-12-22 Thread Dave P. via Digitalmars-d-learn
On Tuesday, 22 December 2020 at 18:10:22 UTC, Dukc wrote: On Friday, 18 December 2020 at 16:18:12 UTC, Dave P. wrote: [...] Honestly, I just want all bits zero. I don’t work with any platforms where null is not 0 and all-zero-bits aggregates can be efficiently represented in static storage.

Re: Floating point values in structs.

2020-12-22 Thread Dukc via Digitalmars-d-learn
On Friday, 18 December 2020 at 16:18:12 UTC, Dave P. wrote: If the compiler is going to introduce the overhead of initializing all the variables anyway, why set it to nan when integer types get set to the useful default of 0? Consider default value of `int*`. It is `null`, not a pointer to a

Re: Floating point values in structs.

2020-12-18 Thread Dave P. via Digitalmars-d-learn
On Friday, 18 December 2020 at 16:23:20 UTC, Adam D. Ruppe wrote: On Friday, 18 December 2020 at 16:18:12 UTC, Dave P. wrote: Is the proper solution to change the struct definition to: yeah that's the best option right now A bit of a pain when porting, but alright. I find the setting

Re: Floating point values in structs.

2020-12-18 Thread Adam D. Ruppe via Digitalmars-d-learn
On Friday, 18 December 2020 at 16:18:12 UTC, Dave P. wrote: Is the proper solution to change the struct definition to: yeah that's the best option right now I find the setting floats to nan pretty bizarre. yeah i wrote about it here not long ago

Floating point values in structs.

2020-12-18 Thread Dave P. via Digitalmars-d-learn
I got burned by behavior of struct initialization I didn’t anticipate last night. Consider a struct: struct Foo { float x, y, z; int a, b, c; } My source C code was initializing it by doing something like: Foo f = {.y = 3} Which uses the C behavior that all the other fields will be