Rounding an equation

Hello

Here is the question is simple how in an equation round the value to 0.5 up or below.

Let me explain, I have an equation of the type = ( IIF (" "D1@Esquisse7" < 500 , 2 , "D1@Esquisse7" / 250 ) ) that I use to slotted holes. My problem if the value is =3.49 I have 3oblong if it's 3.51 I don't have 4. So for a difference of 0.02 I can't be sure to have the same number of oblongs so my sheet metal doesn't mount. So how do you say I round to either the integer sup or inf ?

Thank you

May the force be with you.

1 Like

Hello OBI WAN,

Oh yes it must be annoying! 

We will have to make a choice, either lower or higher.

Try with this:

Lower := IIF ( "D1@Esquisse7" < 500 , 2 , ROUNDING. INF("D1@Esquisse7" / 250 ); 1) )

Superior:= IIF ( "D1@Esquisse7" < 500 , 2 , ROUNDED. SUP("D1@Esquisse7" / 250 ); 1) )

Edit: and it's wrong, rounding is not a SW function...

2 Likes

To round in an equation it's rather the Int() function it seems to me

4 Likes

Watch this video

https://www.youtube.com/watch?v=WGwnZcLcF8k

@+

2 Likes

Indeed sbadenis you're right, rounded up it's under excel dsl. Rounding should be replaced by Int(...).

2 Likes

So after checking:

int gives the rounded down value in all cases

int(3.49) gives 3

for rounded up

int(3.49)+1 gives 4

Otherwise there is also the round() function

Example

round(3.49) ->3

round(3.51)->4

 

EDIT: the time to type my answer and GT22 went through it!

 

 

4 Likes

so you have the walkthrough

Nothing better than 1 good video ;-)

@+ ;-)

2 Likes

Hello

The lynkoa  community has once again proven its effectiveness. A problem 1 hour later no more problem. I want to congratulate all the speakers. Indeed  it is int() that should be used.

I validate @sbadenis who is the first to have put me on the track of the int() despite a video of @gt22 which is very explicit.

In my opinion, there are 2 of you who are good but you have to choose one !!

Thank you very much.

May the force be with you.

2 Likes

Hello, just to add an info, int() returns the integer part of a decimal number.

round() rounds decimal numbers.

It's a shame that my can't specify the number of digits after the decimal point like in other software.

 

2 Likes

For the number of decimal places, it is enough to x 10^n before rounding

e.g. 2 decimal places => int(3.141592*100)/100 = 3.14

4 decimal places => int(3.141592*10000)/10000 = 3.1415

If you want a rounding to 0.5 just add 0.5 

int(3.52+0.5) = 4 or int(3.49+0.5)=3

 

3 Likes