Support Forum

[Question] Rundung von Zahlen


Hallo zusammen

Ich habe folgendes Problem, und komme nicht auf die Lösung:

Ausdruck im Smartpart

qd_stk = ( ( l_matte - ue_1_min - ue_2_min ) / qd_t )

l_matte= 5000mm
ue_1_min= 25mm
ue_2_min= 25mm
qd_t= 150mm

qd_stk ist rein rechnerisch 33, aber ich möchte, das dieser Ausdruck nach folgendem Schema gerundet wird; Beispiel:
32.2= 33
32.5= 33
32.8= 33
33= 34
33.2= 34
33.5= 34
usw., somit immer aufrunden; wenn aber bereits ganze Zahl, dann +1.

Was ich schon probiert habe:

CEIL () => rundet alles auf, aber 33 bleibt 33
INT () + 1 => ganze Zahl und +1. In der Theorie funktioniert es. Aber Allplan macht aus dem oberen Ausdruck in Verbindung mit INT 32 als Resultat. + 1 ergibt wieder 33. Ziel wäre aber 34.

Für mich unlogisch:
INT (33) => 33
INT ( ( l_matte - ue_1_min - ue_2_min ) / qd_t ) = INT ( ( 5000 - 25 - 25 ) / 150 ) = INT ( 33 ) => 32, sollte aber 33 sein

Hat jemand eine Lösung?

Gruss und Danke
Karim

Hallo,

Versuchen Sie dies:

CEIL ( your_value + 0.001 )


@bertrand: Your version will will give a wrong result if "your_Value" is 32.9995

i think this should work

CEIL( INT( Your_Value) + 0.01 )

Allplan Webentwicklung

Private messages must be private. No support request via Private message.

Quote by jvelletti
@bertrand: Your version will will give a wrong result if "your_Value" is 32.9995
i think this should work
CEIL( INT( Your_Value) + 0.01 )

Doesn't work, because of this problem:

l_matte= 5.00
ue_1_min= 0.025
ue_2_min= 0.025
qd_t= 0.15

INT (33) => 33, so with your proposal it would be 34 and correct
INT ( ( l_matte - ue_1_min - ue_2_min ) / qd_t ) = INT ( ( 0.50 - 0.025 - 0.025 ) / 0.15 ) = INT ( 33 ) => result in smartpart is 32, so with your proposal it would be 33 and wrong

Quote by jvelletti
@bertrand: Your version will will give a wrong result if "your_Value" is 32.9995
i think this should work
CEIL( INT( Your_Value) + 0.01 )

Yes, of course if the value has more than 2 decimal places.
But in the examples in the first message, the values have only 1 decimal place.
If you are sure to use only 4 decimal places, use this: CEIL ( your_value + 0.00001 )

There is another solution for this issue using FRA function like this: your_value + 1 - FRA ( your_value )
I avoid to use INT() because in my experience, I have seen that sometimes (very rarely) INT does not give the expected result...


Lies einfach die NACHKOMMASTELLEN aus und wenn diese genau 0 beträgt, lässt du die Ganzzahl um 1 erhöhen, z.B. so:

qd_stck = 32

ganzzahl = ceil (qd_stck)
nachkomma = fra (qd_stck)

print ganzzahl
print nachkomma

if nachkomma = 0 THEN
ganzzahl = ganzzahl + 1
ENDIF

ergebnis = ganzzahl + nachkomma

print ergebnis

Besucht mit gerne auf Youtube
Link

your_value + 1 - FRA ( your_value )
or
CEIL ( your_value + 0.00001 )
is shorter and faster...


Yes Bertand_C,

thats really true, but i always break it down into small steps so that there is an better understanding behind it, for the user.
I hope so :-)
but yes of course, yours is much shorter.

Quote by Bertrand_C
your_value + 1 - FRA ( your_value )

or

CEIL ( your_value + 0.00001 )

is shorter and faster...

Besucht mit gerne auf Youtube
Link


https://connect.allplan.com/ uses cookies  -  More information

Accept