http://d.puremagic.com/issues/show_bug.cgi?id=5971
Summary: Some BigInt ideas Product: D Version: D2 Platform: All OS/Version: All Status: NEW Severity: enhancement Priority: P2 Component: Phobos AssignedTo: nob...@puremagic.com ReportedBy: bearophile_h...@eml.cc --- Comment #0 from bearophile_h...@eml.cc 2011-05-09 15:29:23 PDT --- [idea 1 and 2] I'd like this very simple code to work: import std.bigint, std.conv; void main() { text(BigInt(1)); to!string(BigInt(1)); } ---------------------------- [idea 3] I'd like this very simple code to work, thanks to a T opCast(T:bool)(){} member function: import std.bigint; void main() { BigInt x = BigInt(0); if (x) {} } ---------------------------- (The ideas 4 and 5 have a lower priority, because they are less commonly useful.) [idea 4] I'd like this code to work: import std.bigint; void main() { BigInt b = BigInt(10); auto result = b & 1; } --------------------- [idea 5] Sometimes I like to know how many decimal digits a BigInt is long. Currently (DMD 2.053beta) this is the best way I have found to do it: import std.bigint; void main() { BigInt b = BigInt(91) ^^ 35; const(char)[] bstr; b.toString((const(char)[] s){ bstr = s; }, "d"); int ndigits_b = bstr.length; } But a specific method avoids to keep all the decimal digits: import std.bigint; void main() { BigInt b = BigInt(91) ^^ 35; int ndigits_b = bstr.numDigits(); } (Optionally a base for numDigits(), that defaults to 10.) ----------------------- -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------