Re: Another take on decimal data types

2018-01-11 Thread Robert M. Münch via Digitalmars-d-announce
On 2018-01-08 22:16:25 +, rumbu said: This is my first D finalized project (+16k loc). Great stuff! Will this work in betterC mode? Side-Note: I'm always missing the betterC information or is the philosophy to just try it out? -- Robert M. Münch http://www.saphirion.com smarter |

Re: Another take on decimal data types

2018-01-11 Thread Seb via Digitalmars-d-announce
On Thursday, 11 January 2018 at 11:19:41 UTC, Robert M. Münch wrote: On 2018-01-08 22:16:25 +, rumbu said: This is my first D finalized project (+16k loc). Great stuff! Will this work in betterC mode? Side-Note: I'm always missing the betterC information or is the philosophy to just

Re: Another take on decimal data types

2018-01-11 Thread Robert M. Münch via Digitalmars-d-announce
On 2018-01-11 18:15:23 +, rumbu said: On Thursday, 11 January 2018 at 11:19:41 UTC, Robert M. Münch wrote: Great stuff! Will this work in betterC mode? It will not work without some refactory. Most of phobos/druntime dependencies are minimal an can be rewritten - in fact there are only

Re: Another take on decimal data types

2018-01-11 Thread kdevel via Digitalmars-d-announce
On Thursday, 11 January 2018 at 20:35:03 UTC, kdevel wrote: printf ("%.2f\n", d); This must read writefln ("%.2f", d); Would have expected a compile time/run time error. This prints: 0.735 0.00 <--- expected: 0.74 Good. writefln prints the expected value. 0.735

Re: Another take on decimal data types

2018-01-11 Thread Steven Schveighoffer via Digitalmars-d-announce
On 1/11/18 4:12 PM, kdevel wrote: On Thursday, 11 January 2018 at 20:40:01 UTC, Dmitry Olshansky wrote: What did you expect? To be honest: A compile time error. Modern C compilers can check such format strings. Example: GCC 6: But dmd isn't a C compiler, nor does it have to worry about the

Re: Another take on decimal data types

2018-01-11 Thread H. S. Teoh via Digitalmars-d-announce
On Thu, Jan 11, 2018 at 04:38:57PM -0500, Steven Schveighoffer via Digitalmars-d-announce wrote: > On 1/11/18 4:12 PM, kdevel wrote: > > On Thursday, 11 January 2018 at 20:40:01 UTC, Dmitry Olshansky wrote: > > > What did you expect? > > > > To be honest: A compile time error. Modern C compilers

Re: Another take on decimal data types

2018-01-11 Thread rumbu via Digitalmars-d-announce
On Thursday, 11 January 2018 at 21:24:30 UTC, kdevel wrote: On Thursday, 11 January 2018 at 20:44:13 UTC, kdevel wrote: On Thursday, 11 January 2018 at 20:35:03 UTC, kdevel wrote: <--- loop output missing loop.d ``` import std.stdio; import decimal; void loopme(T) () {

Re: Another take on decimal data types

2018-01-11 Thread Robert M. Münch via Digitalmars-d-announce
On 2018-01-11 15:34:04 +, Seb said: Side-Note: I'm always missing the betterC information or is the philosophy to just try it out? We have now this page: https://dlang.org/spec/betterc.html Hi, thanks. Should have been more precise: An informaiton for every lib if it is compatible

Re: Another take on decimal data types

2018-01-11 Thread kdevel via Digitalmars-d-announce
On Thursday, 11 January 2018 at 22:36:40 UTC, rumbu wrote: 1000 100 10 1 0.1 0.01 0.001 0.0001 1e-05 Regarding printf, I cannot help, this is a C function, has nothing to do with D formatting. Sure. What about the failed comparison: gt.d ``` import std.stdio; import decimal; void loopme(T)

Re: Another take on decimal data types

2018-01-11 Thread Dmitry Olshansky via Digitalmars-d-announce
On Thursday, 11 January 2018 at 21:12:59 UTC, kdevel wrote: On Thursday, 11 January 2018 at 20:40:01 UTC, Dmitry Olshansky wrote: printf ("%.2f\n", d); C’s printf by definition can’t be customized. Sure. “”” GNU C Library lets you define “”” Here is your compatibility story. What

Re: Another take on decimal data types

2018-01-11 Thread kdevel via Digitalmars-d-announce
On Thursday, 11 January 2018 at 20:44:13 UTC, kdevel wrote: On Thursday, 11 January 2018 at 20:35:03 UTC, kdevel wrote: <--- loop output missing loop.d ``` import std.stdio; import decimal; void loopme(T) () { "---".writeln; T e = T(1000); while (e > T(1e-6)) {

Re: Another take on decimal data types

2018-01-11 Thread jmh530 via Digitalmars-d-announce
On Thursday, 11 January 2018 at 18:15:23 UTC, rumbu wrote: [snip] BUT - a very big but - the most important issue is the formatting thing. Even there is no direct dependency on std.format or std.stdio, the formatting mechanism is designed to fit nicely into phobos formatting paradigm. That

Re: Another take on decimal data types

2018-01-11 Thread Dmitry Olshansky via Digitalmars-d-announce
On Thursday, 11 January 2018 at 20:35:03 UTC, kdevel wrote: Great project! On Monday, 8 January 2018 at 22:16:25 UTC, rumbu wrote: - all format specifiers implemented (%f, %e, %g, %a); Really? [...] What's next: - more tests; Here you are: ``` import std.stdio; import decimal; void

Re: Another take on decimal data types

2018-01-11 Thread kdevel via Digitalmars-d-announce
On Thursday, 11 January 2018 at 20:40:01 UTC, Dmitry Olshansky wrote: printf ("%.2f\n", d); C’s printf by definition can’t be customized. Sure. http://www.gnu.org/software/libc/manual/html_node/Customizing-Printf.html What did you expect? To be honest: A compile time error. Modern C

Re: Another take on decimal data types

2018-01-11 Thread rumbu via Digitalmars-d-announce
On Thursday, 11 January 2018 at 11:19:41 UTC, Robert M. Münch wrote: On 2018-01-08 22:16:25 +, rumbu said: This is my first D finalized project (+16k loc). Great stuff! Will this work in betterC mode? It will not work without some refactory. Most of phobos/druntime dependencies are

Re: Another take on decimal data types

2018-01-11 Thread kdevel via Digitalmars-d-announce
Great project! On Monday, 8 January 2018 at 22:16:25 UTC, rumbu wrote: - all format specifiers implemented (%f, %e, %g, %a); Really? [...] What's next: - more tests; Here you are: ``` import std.stdio; import decimal; void main () { decimal32 d = "0.7"; d *= decimal32("1.05");

Re: Another take on decimal data types

2018-01-11 Thread Steven Schveighoffer via Digitalmars-d-announce
On 1/11/18 1:15 PM, rumbu wrote: On Thursday, 11 January 2018 at 11:19:41 UTC, Robert M. Münch wrote: On 2018-01-08 22:16:25 +, rumbu said: This is my first D finalized project (+16k loc). Great stuff! Will this work in betterC mode? It will not work without some refactory. Most of

Re: Another take on decimal data types

2018-01-11 Thread rumbu via Digitalmars-d-announce
On Thursday, 11 January 2018 at 23:57:29 UTC, kdevel wrote: What about the failed comparison: gt.d ``` import std.stdio; import decimal; void loopme(T) () { "---".writeln; T e = 10; while (e > 1e-6) { e /= 10; writeln (e, ' ', e > 1e-6); } } void main () {

Re: Another take on decimal data types

2018-01-11 Thread rumbu via Digitalmars-d-announce
On Thursday, 11 January 2018 at 23:57:29 UTC, kdevel wrote: What about the failed comparison: You are right in fact, there is also a failed comparison. Now corrected.