Re: D 2.066 new behavior

2014-08-22 Thread Paul D Anderson via Digitalmars-d-announce

On Friday, 22 August 2014 at 02:26:38 UTC, safety0ff wrote:
On Friday, 22 August 2014 at 01:54:55 UTC, Paul D Anderson 
wrote:


Is this expected behavior that has never been enforced before, 
or is it something new?


And is anyone else having the same problem?

Paul


Looks like a regression, I've filed it here: 
https://issues.dlang.org/show_bug.cgi?id=13351


Seems to be a duplicate of bug 13294:
https://issues.dlang.org/show_bug.cgi?id=13294


D 2.066 new behavior

2014-08-21 Thread Paul D Anderson via Digitalmars-d-announce
In all previous versions through 2.066 beta 5, the following code 
compiled and ran correctly:


import std.stdio;

T add(T)(in T x, in T y)
{
T z;
z = x + y;
return z;
}

void main()
{
const double a = 1.0;
const double b = 2.0;
double c;
c = add(a,b);
writefln(c = %s, c);// 3.0
c = 1.0;
writefln(c = %s, c);// 1.0
}

From beta 6 onward it no longer compiles. The problem seems to be 
const qualifiers being carried into the template type. Since a 
and b are const double, the function template parameter T is 
const double. So x and y are const, no problem, but z is now 
const also. The following error message is given.


T add(T)(in T x, in T y)
{
T z;
z = x + y;  // Error: Can't modify const expression z
return z;
}

The same problem shows up elsewhere as 'cannot implicitly convert 
const x to x'
and 'none of the overloads are callable using argument types (x) 
const'.


Is this expected behavior that has never been enforced before, or 
is it something new?


And is anyone else having the same problem?

Paul


Re: Decimal Numbers

2014-07-08 Thread Paul D Anderson via Digitalmars-d-announce

On Tuesday, 8 July 2014 at 08:15:28 UTC, Sönke Ludwig wrote:

Am 07.07.2014 23:15, schrieb Paul D Anderson:

On Monday, 7 July 2014 at 03:26:54 UTC, Poyeyo wrote:

Can you add a dub.json and submit it to the dub registry?


etcimon generated a dub.json file which I've merged into 
github. Thanks.


However, I am unable to register the package because it 
requires a
version number, which I don't know how to add. I've used git 
tag and
edited dub.selections.json, but neither seems to be the 
answer. Can

someone enlighten me?

Paul


git tag v0.9.0
git push --tags

should do the trick (as well as any other version instead of 
0.9.0, of course).


Thanks. That did it.


Re: Decimal Numbers

2014-07-07 Thread Paul D Anderson via Digitalmars-d-announce

On Monday, 7 July 2014 at 03:26:54 UTC, Poyeyo wrote:

Can you add a dub.json and submit it to the dub registry?


etcimon generated a dub.json file which I've merged into github. 
Thanks.


However, I am unable to register the package because it requires 
a version number, which I don't know how to add. I've used git 
tag and edited dub.selections.json, but neither seems to be the 
answer. Can someone enlighten me?


Paul


Re: Decimal Numbers

2014-07-06 Thread Paul D Anderson via Digitalmars-d-announce

On Monday, 7 July 2014 at 03:26:54 UTC, Poyeyo wrote:

Can you add a dub.json and submit it to the dub registry?


I can do that but I want to get the 32-, 64- and 128-bit structs 
in place first. Probably by midweek (July 9).


Re: Decimal Numbers

2014-07-04 Thread Paul D Anderson via Digitalmars-d-announce
On Friday, 4 July 2014 at 06:43:15 UTC, Iain Buclaw via 
Digitalmars-d-announce wrote:


6) Rename the file decimal.d to package.d, and module 
eris.decimal.decimal

to eris.decimal


Thanks, will do.

Paul


Re: Decimal Numbers

2014-07-03 Thread Paul D Anderson via Digitalmars-d-announce

Sorry for the unusual formatting.

Paul


Decimal Numbers

2014-07-03 Thread Paul D Anderson via Digitalmars-d-announce

A candidate implementation of decimal numbers (arbitrary-precision
floating-point numbers) is available for review at
https://github.com/andersonpd/eris/tree/master/eris/decimal. This 
is a
substantial rework of an earlier implementation which was located 
at

https://github.com/andersonpd/decimal.

This is a D language implementation of the General Decimal 
Arithmetic
Specification (http://www.speleotrove.com/decimal/decarith.pdf), 
which is
compliant with IEEE-754 and other standards as noted in the 
specification.


The current implementation is not complete; there are a lot of 
TODOs and NOTEs
scattered throughout the code, but all the arithmetic and 
miscellaneous
operations listed in the spec are working, along with decimal 
versions of most
of the functions and constants in std.math. I think it is far 
enough along for

effective review.

Briefly, this software adds the capability of properly rounded
arbitrary-precision floating-point arithmetic to the D language. 
All arithmetic
operations are governed by a context, which specifies the 
precision (number of
decimal digits) and rounding mode for the operations. This same 
functionality
exists in most modern computer languages (for example, 
java.math.BigDecimal).
Unlike Java, however, which uses function syntax for arithmetic 
ops
(add(BigDecimal, BigDecimal), etc.), in D the same arithmetic 
operators that

work for floats or doubles work for decimal numbers. (Of course!)

In this implementation decimal numbers having different contexts 
are different
types. The types are specified using template parameters for the 
precision,

maximum exponent value and rounding mode. This means that
Decimal!(9,99,Rounding.HALF_EVEN) is a different type than
Decimal!(19,199,Rounding.HALF_DOWN). They are largely 
interoperable, however.

Different decimal types can be cast to and from each
other.

There are three standard decimal structs which fit into 32-, 64- 
and 128-bits of
memory, with 7, 16 and 34 digit precision, respectively. These 
are used for
compact storage; they are converted to their corresponding 
decimal numbers for
calculation. They bear the same relation to decimal numbers as 
Walter's

half-float type does to floats.
(http://www.drdobbs.com/cpp/implementing-half-floats-in-d/240146674).
Implementation of these still needs a little work, and will be 
added to github

very shortly.

Major TODO items:

1) The current underlying integer type uses my own big integer 
struct
(eris.integer.extended) rather than std.bigint. This was mainly 
due to problems
with constness and CTFE of BigInts. These problems have since 
been resolved, but
I didn't want to switch over to BigInts until everything was 
working for fear of

introducing new bugs.

2) Integration of Decimal32, Decimal64 and Decimal128 structs are 
not complete.

(See above.)

3) Conversion to and from floats, doubles and reals is currently 
working but it
is slow. (Conversion is through strings: double to string to 
decimal and vice

versa.)

4) Still incomplete implementations of some functions in 
decimal.math: expm1,

acosh, atanh, possibly others.

5) More unit tests (always!).


Re: core.checkedint added to druntime

2014-07-01 Thread Paul D Anderson via Digitalmars-d-announce

Will this be in the 2.066 Beta?

On Wednesday, 18 June 2014 at 01:26:16 UTC, Walter Bright wrote:

https://github.com/D-Programming-Language/druntime/pull/839

While being a very modest piece of code in and of itself, I 
believe this offers a significant opportunity that both D 
compilers and user defined types can exploit.


Not only can it be used to create an efficient safeint data 
type, it can be used to implement multi-precision integer 
arithmetic types.


I'd also like to see it used to replace the various ad-hoc 
schemes currently in use. It should also be used in dmd itself 
for things like detecting array size overflows, which is 
currently done ad-hoc, and detecting overflows in CTFE.


For background information and rationale, see 
http://blog.regehr.org/archives/1139