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

math: Add float32 versions of functions (cosf, sinf, fminf, ...) #725

Closed
nico opened this issue Apr 12, 2010 · 3 comments
Closed

math: Add float32 versions of functions (cosf, sinf, fminf, ...) #725

nico opened this issue Apr 12, 2010 · 3 comments

Comments

@nico
Copy link

nico commented Apr 12, 2010

Before filing a bug, please check whether it has been fixed since
the latest release: run "hg pull -u" and retry what you did to
reproduce the problem.  Thanks.

What steps will reproduce the problem?
1. Use float32s for all your variables
2. Try to compute a cosine

What is the expected output? What do you see instead?

I expected to be able to write

  myfloat32 = math.Cosf(myotherfloat32)

Instead I have to write

  myfloat32 = float32(math.Cos(float64(myotherfloat32)))

This feels clunky and seems to contradict go's "no stuttering" principle.

Which revision are you using?  (hg identify)

6d2593965162 tip
@rsc
Copy link
Contributor

rsc commented Apr 13, 2010

Comment 1:

I think making the math library have two of everything stutters worse.
And why Cosf?  Wouldn't that be the version that takes just a "float", not a "float32"?
For better or worse, we've standardized on using float64 as the interface
to the math library.  If you call cos on float32 so often, you can always
write your own little wrapper in your package
func cos(f float32) float32 { return float32(math.Cos(float64(f))) }

Owner changed to r...@golang.org.

Status changed to WorkingAsIntended.

@nico
Copy link
Author

nico commented Apr 13, 2010

Comment 2:

That's what I'm doing…but it does a bunch of float conversions which aren't really
necessary on x86…in theory, 
the math library could convert float32 directly to the fpu's float80.
Oh well, I guess computer graphics isn't the intended use case of go's standard library.
Not a huge deal, one can 
always write their own math32 library with efficient assembly if this turns out to be a
bottleneck.
(Why Cosf? Because `man cosf`.)

@rsc
Copy link
Contributor

rsc commented Apr 13, 2010

Comment 3:

Mailing lists are better for conversations; feel free to bring up
on golang-nuts if you think they should be there.  It seems very
x86-specific.

@nico nico assigned rsc Apr 13, 2010
@golang golang locked and limited conversation to collaborators Jun 24, 2016
@rsc rsc removed their assignment Jun 22, 2022
This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants