Adaptive Expressions Float division
See original GitHub issueIs your feature request related to a problem? Please describe. While microsoft/botbuilder-js#3527 is about fixing explicit floats, it doesn’t address wanting to get a float as a return object from a division operation.
Consider the following expression: div(11, 2)
the result would be 5
. What if we wanted 5.5
? As of the currently, I think it’d be impossible to achieve. div(11.0, 2)
and even div(float("11.0"), float(2))
won’t work, even with the microsoft/botbuilder-js#3527 fix. Even then, if those two situations were accounted for somehow, it wouldn’t fix when we wanted to explicitly get a precise number from a division operation.
Describe the solution you’d like
A new prebuilt function I believe is the only solution. Something like divPrecise(11, 2, 2)
where the last argument would be the number of decimal places to return. I believe the return object would have to be a string
to accurately return the correct value. That function should return 5.50
Describe alternatives you’ve considered
I think extending the existing div
function could work, but I don’t think it would be backward compatible given the current tests that exist, e.g. div(5, 2, 2)
where each argument is an additional division operation.
Additional context Just that I am really liking this library, and hope that I can use it for this case. I’m happy to take a stab at this function, but since it’s a decent amount of work, would like to have the core team validate that it’s not already possible using other methods I may have overlooked.
Issue Analytics
- State:
- Created 2 years ago
- Comments:12 (9 by maintainers)
I would like @Stevenic / @chrimc62 / @tomlm to comment on this issue as to the approach for resolving it. i.e. new function vs breaking change. My gut says we shouldn’t be introducing a breaking change. Perhaps another option would be to provide an additional optional argument into the div function to specify the output type, but I will let folks chime in here.
Once we understand the scope of the approach here we can look to add into planning.
@stefangomez yes. It would break some tests. There indeed some gaps between different languages naturally. We try the best to align between languages. If the logic of
div
is changed from “C# mode” into “js mode”, the code of C# side should be changed at the same time. It’s a breaking change. We would discuss with team mates to decide whether to implement it.