08-15-2011 05:15 AM
Hallo,
I´m looking for a function in DIAdem to always round up or down. I build myself some but they are old and slow... and they also work only almost perfect, some cases Just wont work right.
The aim is to round figures to 1/100, 5/100, 1/10, 5/10, to numbers, X mod 5 = 0, to x mod 10 = 0, to x mod 50 = 0 and so on.
I want to use it for scalling Report-Diagramms automatically, but with fixed and round scales - also for same scales of one meassurement in different Messures.
Therefor i need the funktion to Round Up always or in Minus Round down always.
If someone has a nice Solution for it i would be very thankfull.
Thanks already for ur surport.
STG
05-06-2015 02:59 PM - edited 05-06-2015 03:01 PM
I'm not sure I fully understand the question, but hopefully this helps:
Frac = Return decimal portion of a number
Trunc = Return Integer portion of a number
intMyResult = Frac(Pi) 'intMyResult = 0.14159265358979
intMyResult = Trunc(-75.5109) 'intMyResult = -75
So a combination of these could give you:
Always Round Up:
If Frac(Val) > 0 then MyResult = Trunc(Val) + 1
Example:
Var =Pi
If Frac(Var) > 0 then
MyResult = Trunc(Var) + 1
Else
MyResult = Var '4
end if
Always Round Down:
MyResult = Trunc(Val)
Example:
Var =Pi
MyResult =Trunc(Var) '3
You can also combine this with multiplying&dividing by 10/100/1000 to round to specific numbers of decimal places
Example:
Var =10.12345
Var = Var *100
Var =Trunc(Var)
Var = Var /100
MyResult = Var '10.12
-Josh
Engineering Technician
John Deere Power Systems
05-11-2015 05:18 PM
Hi STG,
Check out the DIAdem 2015 Beta version, there is a new "Round Channels" ANALYSIS function in the "Basic Mathematics" palette that should make you happy.
Brad Turpin
DIAdem Product Support Engineer
National Instruments
05-11-2015 06:34 PM
Ok Brad...You got my attention.
Where can I find the DIAdem 2015 BETA version?
Can’t wait !!
05-12-2015 02:11 AM
Hello Spidy,
You can sign up for the BETA program (at no cost) here:
Just follow the instructions for the DIAdem 2015 BETA program.
Otmar