Re: readText for large files on Windows.
Thanks. The bug is created. https://issues.dlang.org/show_bug.cgi?id=14469
readText for large files on Windows.
This function works fine for large text files like 100Mb or 1Gb but failed when I tried to read 6Gb file. This happens on Windows x64. The possible reason that it uses read(in char[], size_t) function and on windows it calls GetFileSize. This function returns file size as 32 bit value. If you need size for files larger then 4Gb then this function provides out parameter where you can pass reference to another 32 bit value. But in DMD 2.067 this function is called as auto size = trustedGetFileSize(h, null); thus we never get correct size for files larget then 4Gb. Is it a bug?
Re: Best practices for reading public interfaces
On Sunday, 22 February 2015 at 12:13:02 UTC, MrSmith wrote: You can also fold all the function bodies in your editor, this helps me to read massive sources. Oh, I almost forgot about this feature, never used it in C++ but for D it looks promising. Thanks!
Re: Best practices for reading public interfaces
On Saturday, 21 February 2015 at 20:56:26 UTC, anonymous wrote: On Saturday, 21 February 2015 at 20:46:09 UTC, Kenny wrote: b) Write DDocs and read documentation. The problem here is that I'm going to use D only for my own projects and in the last time I tend to write less documentation, for example I do not write it for the most methods of Vector3D. If you're only interested in the signatures, empty documentation comments give you that. Is is possible to generate signatures without modifying source code?
Best practices for reading public interfaces
I like D modules and it's a major point in the list of major points why I like D (there is also the second not so nice wft-list but it's for another post). I'm annoyed with C++ includes and I'm tired to create 2 files every time when I need to add something new to the project... But I must admit that one thing I like in header files is that it is a convenient way to read public interfaces. In D we have interface specification and implementation in a single file and also one approach with unit testing is to put them immediately after functions which makes writing unit tests even more easy task (and I like it very much) but again it makes the gaps between declarations even wider. So, what are the common approaches for reading public interfaces in D programs? Especially it would be great to see the answers of developers who work with more or less big codebases. The few possible solution I'm thinking about at the moment: a) Provide D interfaces for corresponding classes (but probably it's only for more or less complex abstractions and also I won't use it for Vector3D, also very often I use just regular functions). b) Write DDocs and read documentation. The problem here is that I'm going to use D only for my own projects and in the last time I tend to write less documentation, for example I do not write it for the most methods of Vector3D. c) Do nothing special, just write D modules and try to figure out public interfaces reading its code. Maybe it works in practice. Thanks, Artem.
Re: Fun with floating point
nope, this is a bug in your code. compiler (by the specs) is free to perform intermediate calculations with any precision that is not lower than a highest used type (i.e. not lower that `float`'s one for `while` condition (`f + eps != f`). it may be even infinite precision, so your code may not exit the loop at all. Thanks, it's clear now. I still have one question in the above post, I would appreciate if you check it too.
Re: Fun with floating point
For example, according to IEEE-754 specification if we work with 32bit floating point numbers (floats in D) then the following pseudo code prints 'Works'. F32 f = 16777216.0f; F32 f2 = f + 0.1f; if is_the_same_binary_presentation(f, f2) Print(Works); As I understand D does not guarantee this. Please confirm if it's correct. One clarification: In D the following should always print 'Works' float f = 16777216.0f; float f2 = f + 1.0f; if (f == f2) writeln(Works); I asked more about this case: float f = 16777216.0f; if (f == f + 1.0f) writeln(Works); Although all operands are 32bit FP the result is not guaranteed to be equal to the result for FP32 computations as specified by IEEE-754.
Re: Fun with floating point
i think you are mixing two things here. IEEE doesn't specify which internal representation compilers should use, it only specifies the results for chosen representation. so if D specs states that `float` calculations are always performing with `float` precision (and specs aren't), your sample should work. but the specs says that compiler is free to promote such expression to any type it wants, it just should not loose precision. so the actual type of `f` in `f == f + 1.0f` can be freely promoted to `double`, `real` or even to some GMP representation. It's clear now, thanks!. Also thanks to everyone for the answers, it was very helpful.
Re: Fun with floating point
There is no right or wrong when you compare floating point values for equality (and inequality) unless those values can be represented exactly in the machine. 1.0 is famously not representable exactly. (It is similar to how 1/3 cannot be represented in the decimal system.) Here I tested one aspect of IEEE-754 floating point behavior (not ordinary floating point calculations for daily job). All integers can be represented exactly until some maximum value. I believe that first section from http://dlang.org/float.html explains why behavior of my program should not be considered a bug in the compiler. But does it mean that due to these rules the results of the computation are not according to IEEE-754 for some specified floating point format (32 bit single precision in my examples)? For example, according to IEEE-754 specification if we work with 32bit floating point numbers (floats in D) then the following pseudo code prints 'Works'. F32 f = 16777216.0f; F32 f2 = f + 0.1f; if is_the_same_binary_presentation(f, f2) Print(Works); As I understand D does not guarantee this. Please confirm if it's correct.
Fun with floating point
Hi, D community! I have this program: import std.stdio; import std.conv; int main(string[] argv) { float eps = 1.0f; float f = 0.0f; while (f + eps != f) f += 1.0f; writeln(eps = ~ to!string(eps) ~ , max_f = ~ to!string(f)); return 0; } According to the languge specification what result would you expect from its execution? When running similar C++ program (VS 2013) the loop terminates and I get t = 2^24 = 16777216. Does D language specifies that loop will be terminated for this program or ? I compiled with DMD and it hungs. Details about assembly generated by DMD can be found here: http://stackoverflow.com/questions/28380651/floating-point-maxing-out-loop-doesnt-terminate-in-d-works-in-c Thanks.
Re: Fun with floating point
And sory for the typos, cannot find edit functionality here..