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

Handle overflow in DesignScript and core nodes #11075

Merged
merged 2 commits into from
Aug 31, 2020

Conversation

mmisol
Copy link
Collaborator

@mmisol mmisol commented Aug 28, 2020

Purpose

Operations that may result in an integer overflow in DesignScript code
or core nodes now display a warning when one occurs. The result is
maintained as it was, in order to avoid introducing incompatibilities.

Declarations

Check these if you believe they are true

  • The codebase is in a better state after this PR
  • Is documented according to the standards
  • The level of testing this PR includes is appropriate
  • User facing strings, if any, are extracted into *.resx files
  • All tests pass using the self-service CI.
  • Snapshot of UI changes, if any.
  • Changes to the API follow Semantic Versioning and are documented in the API Changes document.
  • This PR modifies some build requirements and the readme is updated

Reviewers

@aparajit-pratap @reddyashish

FYIs

@DynamoDS/dynamo

Operations that may result in an integer overflow in DesignScript code
or core nodes now display a warning when one occurs. The result is
maintained as it was, in order to avoid introducing incompatibilities.
@mmisol
Copy link
Collaborator Author

mmisol commented Aug 28, 2020

Some inconsistencies I found while doing this:

  • Math.Factorial is one of the few Math nodes that handled overflow. It returns null, in contrast with other Math nodes.
  • Math.Abs does not handle overflow, but .NET seems to do it internally because it throws. I would label this as an inconsistency in .NET.
  • Math.Round returns a double, while ceiling and floor return integers. This means overflow cannot happen for Math.Round.

@@ -156,6 +156,9 @@
<data name="FromObjectObsolete" xml:space="preserve">
<value>This node is obsolete, please use "String from Object"</value>
</data>
<data name="IntegerOverflow" xml:space="preserve">
<value>The operation resulted in an integer overflow. Its result may be unexpected.</value>
Copy link
Contributor

Choose a reason for hiding this comment

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

@Amoursol does this error message sound okay? Any scope for improvement?

Copy link
Contributor

Choose a reason for hiding this comment

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

The term 'overflow' will not make sense to an end user. I suggest we keep it to be technically correct, but change the second sentence:

"The operation resulted in an integer overflow. Integer overflow occurs when a numeric value falls outside of the range in which that integer can be represented - either higher than the maximum, or lower than the minimum. This may cause the integer value to wrap around the maximum or minimum value and generate an unexpected result."

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@Amoursol The error message seem rather long. Would you be ok if I added a linked explanation as an html document for the documentation browser?

Copy link
Contributor

Choose a reason for hiding this comment

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

Totally cool to have it as a verbose explanation in the Doc Browser, instead yes :)

Copy link
Collaborator Author

@mmisol mmisol Aug 31, 2020

Choose a reason for hiding this comment

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

@Amoursol Added it to the doc browser, including how to fix and a code sample. Let me know if there is something you would like to change.

Part 1
doc_1

Part 2 (after scrolling down a little)
doc_2

EDIT: I forgot to include the first paragraph before.

Copy link
Contributor

Choose a reason for hiding this comment

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

All comments handled via Slack, but for logging reproduced here:

Under How to Fix: I would add: “When working with very large numbers, try to use the double (Decimal placed number) type…” , and, “…type instead of the int (Whole number) type.”

image

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Thanks for the help with the docs @Amoursol ! I have just pushed the new version including your changes. I'll post just the end, the previous section did not change:
Screen Shot 2020-08-31 at 5 19 23 PM

Copy link
Contributor

Choose a reason for hiding this comment

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

LGTM! Did you also include the parenthesis callouts of (Whole number) for int, and (Decimal place number) for double?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes, I did. Sorry, I forgot to include a screenshot of it.

Copy link
Contributor

Choose a reason for hiding this comment

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

Perfect, thank you @mmisol. No need to screenshot 😊

Copy link
Contributor

@aparajit-pratap aparajit-pratap left a comment

Choose a reason for hiding this comment

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

@mmisol thanks for fixing this. Aside from the question to Sol, this looks good.

@mmisol mmisol merged commit b06a168 into DynamoDS:master Aug 31, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants