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

Add math.Sqrt #6941

Closed
StarsoftAnalysis opened this issue Feb 23, 2020 · 3 comments
Closed

Add math.Sqrt #6941

StarsoftAnalysis opened this issue Feb 23, 2020 · 3 comments

Comments

@StarsoftAnalysis
Copy link
Contributor

What would it take to add to Hugo’s templates the ability to calculate square roots?

We already have basic arithmetic (add, mul, etc.) and some other Go functions (math.Floor, math.Round, etc.), but not math.Sqrt.

Why would I want to calculate square roots? Because I’m trying to display a group of differently-shaped images so that they all take up the same area on the screen. See MathCentral for the formula.

So I’d like to be able to use math.Sqrt in my shortcode.

Meanwhile, I'll have a look at the code and see if I can come up with a pull request for such a feature.

@bep bep changed the title Square roots? Add math.Sqrt Feb 23, 2020
@bep bep added Enhancement and removed Proposal labels Feb 23, 2020
@bep bep added this to the v0.66 milestone Feb 23, 2020
@Jos512
Copy link

Jos512 commented Feb 23, 2020

See MathCentral for the formula.
I'll have a look at the code and see if I can come up with a pull request for such a feature.

Luckily we don't have to implement the formula ourselves. 🙂 Go's math.Sqrt() function (here) provides the capability we need. You can use that function to implement the square root behaviour in Hugo.

It looks like Hugo defines the math functions in the math.go file. That's a good place to start.

Good luck!

@StarsoftAnalysis
Copy link
Contributor Author

I've created a patch and a pull request -- at least I think I have: I'm not very experienced at this Github thing.

@github-actions
Copy link

github-actions bot commented Feb 6, 2022

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 6, 2022
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