D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 7155 - inconsistent .stringof
Summary: inconsistent .stringof
Status: NEW
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: All All
: P4 enhancement
Assignee: No Owner
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-12-22 10:59 UTC by timon.gehr
Modified: 2024-12-13 17:57 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description timon.gehr 2011-12-22 10:59:57 UTC
For example, all of those fail:
static assert(100001f.stringof     == "100001f");
static assert(1000001f.stringof    == "1000001f");
static assert([100001f].stringof   == "[100001f]");
static assert([1000001f].stringof  == "[1000001f]");

static assert(100001.0.stringof    == "100001.0");
static assert(1000001.0.stringof   == "1000001.0");
static assert([100001.0].stringof  == "[100001.0]");
static assert([1000001.0].stringof == "[1000001.0]");

static assert(TypeTuple!(int, 1).stringof == "(int, 1)");

currently:

100001f.stringof     == "100001",
1000001f.stringof    == "1e+06
[100001f].stringof   == "[100001F]"
[1000001f].stringof  == "[0xf.4241p+16F]"

100001.0.stringof    == "100001"
1000001.0.stringof   == "1e+06"
[100001.0].stringof  == "[100001]"
[1000001.0].stringof == "[0xf.4241p+16]"

TypeTuple!(int,double).stringof == "(int, double)" // fine
TypeTuple!(int, 1).stringof == "tuple((int),1)"    // oO ?

Preferably the constants should all be represented in decimal but in a way that preserves their value when mixed in at another place. (with the minimum number of digits)
Comment 1 dlangBugzillaToGithub 2024-12-13 17:57:16 UTC
THIS ISSUE HAS BEEN MOVED TO GITHUB

https://github.com/dlang/dmd/issues/18389

DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB