Grasshopper

algorithmic modeling for Rhino

Scientific Notation

By default Grasshopper uses the Scientific notation when dealing with particularly large or small numbers.

For example:

What scientific notation displays is the important numbers and where the decimal place should be.

The reason it only shows the first 5 numbers that make up 1,000,000 is because anything smaller than 100 is considered insignificant when talking about 1 million. Think of it like this if 1 million represents an Olympic size swimming pool then 10 would represent the volume of a full tank of petrol for an average family car. You would have to stand there for an extremely long time to fill up the pool from a petrol pump.

It's important to know that these insignificant digits are still there for the purpose of calculations but are just not being displayed.

There are times when you may want to display these numbers in a format that makes more sense, for these occasions we can use the Format() function.


Format() Function

For versions BEFORE 0.9.0001 the VB Format Function is available through the Expression Components found on the Math Tab > Script Panel

Either by using the F input* or the Expressions Editor found on the Context Menu you can apply a format mask to the x input.

* except FxN

Anatomy of the formatting function above:

Format(..............................) <-- VB function

Format("........................."....) <-- Display String

Format("{0....................}"....) <-- Place Holder for first variable

Format("{0:0.000000000}"...) <-- Format Mask for 9 decimal places

Format("{0:0.000000000}", x) <-- Variable

This can be applied to points and their components:


For versions AFTER 0.9.0001 there is a dedicated Format Component or you can use the Expressions Components successor Evaluate.


For more information on the tags used in the Format Function see these links.

Standard formatting tags

Custom formatting tags

WARNING:

If you format a number to be displayed in this way it becomes a string and will no longer have the complete Real number available for calculations. Always use the input to the format function for further requirements in calculations.

Views: 33868

Replies to This Discussion

ps. there will be a dedicated Format component in 0.9.0001, but the formatting masks will operate in the same way.

--

David Rutten

david@mcneel.com

Poprad, Slovakia

RSS

About

Translate

Search

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service