digitalmars.D - Does std.bigint compile under D2.40?
- Paul D. Anderson (8/8) Feb 16 2010 I'm close to wrapping up a decimal (bigfloat) module for D (coming soon ...
- Don (8/17) Feb 16 2010 I'm planning on replacing std.bigint with an upgraded version of
- Paul D. Anderson (6/6) Feb 26 2010 Don Wrote:
- Don (2/12) Feb 26 2010 http://www.dsource.org/projects/phobos/browser/trunk/docsrc/operatorover...
- Paul D. Anderson (2/15) Feb 26 2010
- bearophile (16/17) Feb 26 2010 It says:
- Paul D. Anderson (2/15) Feb 26 2010 This was also helpful to me, when I finally found it: http://www.prowiki...
- bearophile (6/8) Feb 26 2010 It misses an important use case of bigints: safe integer values that mos...
- Don (2/19) Feb 26 2010 Yes, but it was not accepted.
- Jay Norwood (2/2) Feb 24 2010 I like this guy's C++ template arbitrary precision code.
I'm close to wrapping up a decimal (bigfloat) module for D (coming soon to dsource!) and, as you might imagine, it uses std.bigint heavily. I upgraded my compiler from D2.30 to D2.40 and got error messages regarding conflicts between struct constructors and struct initializers. I cleaned up my code, but when I tried to compile again it complained about struct initializers in std.bigint. I'm away from my home computer, so I can't give specifics on the error(s), but I know bigint is overdue for a rework, and that it has been missing from the phobos documentation for a long time. My question is whether anyone else is using std.bigint and has experienced this problem. For what it's worth, there are several features that I wish were present in std.bigint, mostly dealing with decimal representation: 1. Return the number of decimal digits are in a given bigint. 2. Return the first or last decimal digits in a bigint. 3. Some sort of decimal shift; divide/multiply by a given power or ten. For the time being I've implemented these in my Decimal class, but are they of wider use to anyone else? (Note: I'm sure there are more efficient ways to implement these functions, and including them in std.bigint may allow these efficiency gaings.)
Feb 16 2010
Paul D. Anderson wrote:I'm close to wrapping up a decimal (bigfloat) module for D (coming soon to dsource!) and, as you might imagine, it uses std.bigint heavily.Cool!I upgraded my compiler from D2.30 to D2.40 and got error messages regarding conflicts between struct constructors and struct initializers. I cleaned up my code, but when I tried to compile again it complained about struct initializers in std.bigint. I'm away from my home computer, so I can't give specifics on the error(s), but I know bigint is overdue for a rework, and that it has been missing from the phobos documentation for a long time. My question is whether anyone else is using std.bigint and has experienced this problem.I'm planning on replacing std.bigint with an upgraded version of tango.math.bigint. Haven't got around to it yet (distracted by fixing compiler bugs <g>, and anyway the new operator overloading syntax will appear in the next release). You should probably take a look at Tango bigint to get an idea of how it differs from the current std.bigint. Eg, it supports efficient powers.For what it's worth, there are several features that I wish were present in std.bigint, mostly dealing with decimal representation: 1. Return the number of decimal digits are in a given bigint. 2. Return the first or last decimal digits in a bigint. 3. Some sort of decimal shift; divide/multiply by a given power or ten.
Feb 16 2010
Don Wrote: <snip> and anyway the new operator overloading syntax will appear in the next release). </snip> Can you point me to info on what the new syntax will look like? Thanks, Paul
Feb 26 2010
Paul D. Anderson wrote:Don Wrote: <snip> and anyway the new operator overloading syntax will appear in the next release). </snip> Can you point me to info on what the new syntax will look like? Thanks, Paulhttp://www.dsource.org/projects/phobos/browser/trunk/docsrc/operatoroverloading.dd
Feb 26 2010
Gracias. Don Wrote:Paul D. Anderson wrote:Don Wrote: <snip> and anyway the new operator overloading syntax will appear in the next release). </snip> Can you point me to info on what the new syntax will look like? Thanks, Paulhttp://www.dsource.org/projects/phobos/browser/trunk/docsrc/operatoroverloading.dd
Feb 26 2010
Don:http://www.dsource.org/projects/phobos/browser/trunk/docsrc/operatoroverloading.ddIt says: 223 logical negation operator. More obscurely absent is a unary operator 224 to convert to a bool result. ... 234 if (e) => if (e.opCast!(bool)) 235 if (!e) => if (!e.opCast!(bool)) ... 238 $(P etc., whenever a bool result is expected. This only happens, however, for 239 instances of structs. Class references are converted to bool by checking to 240 see if the class reference is null or not. I have asked for this several times, but I didn't know that was accepted :-) So if you change a class into a struct or the opposite, you have to be careful of changing all such points where the boolean value is asked for. What does it happen if this semantics is extended to class instances too? I guess this is an unthinkable change. Bye, bearophile
Feb 26 2010
Don Wrote:Paul D. Anderson wrote:This was also helpful to me, when I finally found it: http://www.prowiki.org/wiki4d/wiki.cgi?LanguageDevel/DIPs/DIP7Don Wrote: <snip> and anyway the new operator overloading syntax will appear in the next release). </snip> Can you point me to info on what the new syntax will look like? Thanks, Paulhttp://www.dsource.org/projects/phobos/browser/trunk/docsrc/operatoroverloading.dd
Feb 26 2010
Paul D. Anderson:This was also helpful to me, when I finally found it: http://www.prowiki.org/wiki4d/wiki.cgi?LanguageDevel/DIPs/DIP7That page contains this point:non-linear operations (*, /, etc), and memory allocation. Expression optimisation is unimportant, except for efficient handling of temporaries.<It misses an important use case of bigints: safe integer values that most times are about as small as normal ints/longs, but can become two or more times longer in uncommon situations, for example an unusually large input. This use case asks bigints to be very fast when they can fit in just 30-64 bits (so such number can be put inside the struct that represents the bigint, fully on the stack). In this case expression optimization becomes a little more important. (Python2.x uses such numbers, it shows you can write a large number of programs using just them, if they have that stack optimization for small values). Bye, bearophile
Feb 26 2010
Paul D. Anderson wrote:Don Wrote:Yes, but it was not accepted.Paul D. Anderson wrote:This was also helpful to me, when I finally found it: http://www.prowiki.org/wiki4d/wiki.cgi?LanguageDevel/DIPs/DIP7Don Wrote: <snip> and anyway the new operator overloading syntax will appear in the next release). </snip> Can you point me to info on what the new syntax will look like? Thanks, Paulhttp://www.dsource.org/projects/phobos/browser/trunk/docsrc/operatoroverloading.dd
Feb 26 2010
I like this guy's C++ template arbitrary precision code. http://www.hvks.com/Numerical/arbitrary_precision.html
Feb 24 2010