Dim as Integer only rounds up

Dim as Integer only rounds up

Anonymous
Not applicable
804 Views
6 Replies
Message 1 of 7

Dim as Integer only rounds up

Anonymous
Not applicable

Hello,

 

if i want to round up an integer up, so that it only ends up.

For example: value is 0.01 but the integer wil be 1.

 

does somenone know how i can program this?

 

Thanks, Joop

0 Likes
805 Views
6 Replies
Replies (6)
Message 2 of 7

dutt.thakar
Collaborator
Collaborator

Check the below example that may help you. Please note that, when you say integer, as a default it only allows the whole number, so fundamentally you can not add a decimal number in an integer data type. In your iLogic code, I would suggest if you are using the decimal number (like 0.01) please assign them Double or Float data type.

 

For your query here, you can use Math.Ceiling function in iLogic to round up any decimal number. see below example that will help you.

 

x = 0.01 ' assigned x as 0.01

y = Math.Ceiling(x) ' rounding up x to 1 and storing in another variable called y

MessageBox.Show(y) ' showing y in messagebox.

 

 

If this answer has solved your problem please ACCEPT SOLUTION and hit like if you found it helpful..!


Regards,
Dutt Thakar
LinkedIn
0 Likes
Message 3 of 7

_dscholtes_
Advocate
Advocate
0 Likes
Message 4 of 7

Anonymous
Not applicable

i read your post over the Snippets of Math. this should work but how can i set the ceil() in a code?

0 Likes
Message 5 of 7

dutt.thakar
Collaborator
Collaborator

@Anonymous 

 

You can do like this Ceil(0.01). Enter the value that you want to round up in bracket, To return that value, you need to store it in any parameter or variable and then you can use it.

 

Also, read carefully my above post where I have tried explaining the same with an example.

 

Hope this will help you.

If this answer has solved your problem please ACCEPT SOLUTION and hit like if you found it helpful..!


Regards,
Dutt Thakar
LinkedIn
0 Likes
Message 6 of 7

WCrihfield
Mentor
Mentor

Are you talking about doing math and conversions within iLogic rules, VBA macro, or within the equation of a parameter within the parameters dialog box.

If you are asking about equations in parameters, via the dialog box, see the following links for reference.

Expression Reference for Numeric Parameters 

Functions, prefixes, and algebraic operators 

If you are asking about math and unit conversions within iLogic rules, see the following links for reference.

Math Functions Reference (iLogic) 

Math Functions (Visual Basic) 

Type Conversion Functions (Visual Basic) 

 

If this solved your problem, or answered your question, please click ACCEPT SOLUTION.
Or, if this helped you, please click (LIKE or KUDOS) 👍.

If you have time, please... Vote For My IDEAS 💡or you can Explore My CONTRIBUTIONS

Inventor 2021 Help | Inventor Forum | Inventor Customization Forum | Inventor Ideas Forum

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 7 of 7

Anonymous
Not applicable

thank you for your help, i'm going to read the linked pages.

0 Likes