Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Taking the sqrt of an integer shouldn't require an explicit cast. #9888

Open
dlangBugzillaToGithub opened this issue Jul 13, 2010 · 3 comments

Comments

@dlangBugzillaToGithub
Copy link

dsimcha (@dsimcha) reported this on 2010-07-13T13:56:00Z

Transfered from https://issues.dlang.org/show_bug.cgi?id=4455

CC List

  • bearophile_hugs
  • dlang (@Vild)

Description

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).
@dlangBugzillaToGithub
Copy link
Author

bearophile_hugs commented on 2010-07-13T14:25:18Z

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.

@dlangBugzillaToGithub
Copy link
Author

dsimcha commented on 2010-08-11T19:45:25Z

Fixed SVN.

@dlangBugzillaToGithub
Copy link
Author

dlang (@Vild) commented on 2019-09-12T07:46:28Z

Still there, or crept in again.

@LightBender LightBender removed the P3 label Dec 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants