Skip to content
This repository has been archived by the owner on Jun 10, 2024. It is now read-only.

Add NumberConversionTypePreference for strings #16

Merged
merged 2 commits into from
Apr 6, 2023

Conversation

JBridenbaugh
Copy link
Contributor

Added the ability to convert string values to a double instead of a decimal. Doubles have more compatibility with other types so it is nice to have the option to convert a string to a double.

Copy link
Contributor

@petli petli left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the submission! It is a bit curious that Numbers parsed strings as decimal, since the grammar always parsers numbers as doubles:
https://github.com/ncalc/ncalc-async/blob/master/src/Grammar/NCalc.g#L221

A potential problem with the conversion of strings to numbers is that double.Parse() or decimal.Parse() will use the current culture. It can also be a feature for some users. However, this have always been the case, so I don't think it needs to be addressed in this PR.

@petli petli merged commit 80d0e3c into ncalc:master Apr 6, 2023
@petli
Copy link
Contributor

petli commented Apr 6, 2023

Published as v3.2.6: https://www.nuget.org/packages/NCalcAsync/3.2.6

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants