Skip to content

Conversation

@Chaosus
Copy link
Member

@Chaosus Chaosus commented Nov 5, 2025

I think this function is a useful addition. Previously, user may use: pow(number, 1.0 / 3.0) - compared to it, according to C++ documentation (https://en.cppreference.com/w/cpp/numeric/math/cbrt) this function should work faster and more precise.

@Ivorforce
Copy link
Member

Ivorforce commented Nov 6, 2025

Is there a proposal for this function?
cbrt being faster is probably not relevant for the bindings, since the bottleneck is probably GDScript / the binding layers rather than the calculation itself.
I can see it being useful for its improved preciseness, but that depends on whether users are actually using cubic roots sometimes?

@AThousandShips
Copy link
Member

AThousandShips commented Nov 6, 2025

Considering we only use it exactly twice in the whole codebase I think is indicative of that we should gauge if the community actually needs this and the precision difference (the actual difference is almost completely negligible, probably within one or two epsilon, note also that unlike std::sqrt, std::cbrt is not guaranteed to be exact), so the main value would be that std::cbrt handles negative values unlike std::pow, but that's trivial to work around though you'd need a little guard code

@Mickeon
Copy link
Member

Mickeon commented Nov 6, 2025

Mmm. I'd say exposing this function would be quite hasty, especially without any corresponding proposal.
If there other cases in the codebase where it would be used, then it makes sense to keep it in Math, otherwise I don't know...

@AThousandShips
Copy link
Member

I did a search and there are no cases where cbrt can be dropped in directly, i.e. no cases with a constant pow(x, 1 / 3.0)

@Mickeon
Copy link
Member

Mickeon commented Nov 6, 2025

Yyyeah, it's too niche. I would personally move this function to editor_audio_buses.cpp, where it's used, and give it a longer name for clearness.

@AThousandShips
Copy link
Member

One method I'd say we should consider adding is log10, it's used in 14 places and has a lot of relevant uses, but it's also trivial to work around, but it does have more of a regular use case

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants