Grasshopper

algorithmic modeling for Rhino

Hi All,

I'm often converting numerical strings (strings limited to the characters 1234567890) to integers for IDing and scheduling things. However, I've recently run into an issue where numerical strings exceeding a certain text length will no longer convert. Is there a workaround for this in Grasshopper or Python? Tips appreciated. Image below.

(The red component error text reads "1. Data conversion failed from Text to Integer")

Thanks,

B

Views: 1465

Replies to This Discussion

I found the answer - basically my lack of computer science knowledge...

https://en.wikipedia.org/wiki/Integer_(computer_science)

Yeah integers have a limited range. They cannot represent numbers bigger than 2,147,483,647

Grasshopper uses 32-bit integers (details on the type here). 

If you're willing to write your own code then you can switch to 64-bit integers, which have a much bigger range, but it too is limited. Ultimately there's a BigInteger type which is not limited (except in the ridiculous sense that eventually you will run out of memory to store the number). However neither of these types are supported by Grasshopper, so they can only exist within custom code.

Thanks David. I'm able to work well within the 32-bit integer limit for the task at hand, but this information is useful in terms of generating error messages in the event that the end user shoves a paragraph or something crazy into the input.

Attachments:

RSS

About

Translate

Search

Photos

  • Add Photos
  • View All

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service