Re: Bug or Feature: unsigned integer overflow

2019-12-13 Thread berni44 via Digitalmars-d-learn
On Saturday, 14 December 2019 at 07:09:30 UTC, Tobias Pankrath wrote: void main() { auto x = 9223372036854775808; // long.max + 1 } You need to tell, that this is an unsigned long literal, else the compiler treats it as an int: void main() { auto x = 9223372036854775808UL; // long.ma

Bug or Feature: unsigned integer overflow

2019-12-13 Thread Tobias Pankrath via Digitalmars-d-learn
void main() { auto x = 9223372036854775808; // long.max + 1 } onlineapp.d(3): Error: signed integer overflow According to spec x should be of type ulong and this should compile? It indeed compiles if I add the uL postfix. Is this a bug or indented behaviour?

Re: d programs conversion to c

2019-12-13 Thread BoraxMan via Digitalmars-d-learn
On Wednesday, 11 December 2019 at 18:54:49 UTC, jicman wrote: Greetings! I am trying to see if there are any converters out there from d code to c. Anyone knows? Thanks. josé I don't think there would be any. The BetterC subset is as good as using C. Why specifically do you want to con

Re: D's equivalent List Comprehension

2019-12-13 Thread mipri via Digitalmars-d-learn
On Friday, 13 December 2019 at 15:20:02 UTC, Jesse Phillips wrote: I had mentioned my take on list comprehension here: https://forum.dlang.org/post/qslt0q$2dnb$1...@digitalmars.com#post-ycbohbqaygrgmidyhjma:40forum.dlang.org However someone put together a more comprehensive tutorial of its pow

D's equivalent List Comprehension

2019-12-13 Thread Jesse Phillips via Digitalmars-d-learn
I had mentioned my take on list comprehension here: https://forum.dlang.org/post/qslt0q$2dnb$1...@digitalmars.com#post-ycbohbqaygrgmidyhjma:40forum.dlang.org However someone put together a more comprehensive tutorial of its power. So I took the opportunity to demonstrate the parallel in D. ht

Re: Mapping float to ulong in CTFE

2019-12-13 Thread berni44 via Digitalmars-d-learn
Yeah, it worked (at least for %a): static assert(format!"%.3a"(1.0f) == "0x1.000p+0");

Re: Mapping float to ulong in CTFE

2019-12-13 Thread berni44 via Digitalmars-d-learn
On Thursday, 12 December 2019 at 19:39:16 UTC, Petar Kirov [ZombineDev] wrote: You can use a C-style pointer reinterpret cast like this: uint test(float f) { return *cast(uint*)&f; } Make sure that source and destination types have the same size. Hey, great! :-)