Issue 4455 - Taking the sqrt of an integer shouldn't require an explicit cast.
Summary: Taking the sqrt of an integer shouldn't require an explicit cast.
Status: REOPENED
Alias: None
Product: D
Classification: Unclassified
Component: phobos (show other issues)
Version: D2
Hardware: All All
: P3 normal
Assignee: No Owner
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-07-13 13:56 UTC by David Simcha
Modified: 2024-12-01 16:13 UTC (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description David Simcha 2010-07-13 13:56:00 UTC
This one's been around for ages, but has just now started bothering me enough to file a bug report:

import std.math;

void main() {
    uint num = 1;
    auto ans = sqrt(num);
}

Error:
test.d(5): Error: function std.math.sqrt called with argument types:
	((uint))
matches both:
	std.math.sqrt(float x)
and:
	std.math.sqrt(real x)

I guess the solution is to make long and ulong overloads that forward to std.math.sqrt(real x).
Comment 1 bearophile_hugs 2010-07-13 14:25:18 UTC
Partially unrelated: an efficient D compiler can desire to implement the sqrt with SSE instructions like SQRTSS RSQRTSS SQRTPS and RSQRTPS, that have floats or doubles in input or output. So I think a double sqrt(double) too can be useful, to avoid the useless argument passing of 10-12-16 bytes (necessary for an argument of type real) for the computation of sqrt on a double.
Comment 2 David Simcha 2010-08-11 19:45:25 UTC
Fixed SVN.
Comment 3 Berni 2019-09-12 07:46:28 UTC
Still there, or crept in again.
Comment 4 dlangBugzillaToGithub 2024-12-01 16:13:29 UTC
THIS ISSUE HAS BEEN MOVED TO GITHUB

https://github.com/dlang/phobos/issues/9888

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