DIAdem

cancel
Showing results for 
Search instead for 
Did you mean: 

always round up or down

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

0 Kudos
Message 1 of 5
(4,550 Views)

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

0 Kudos
Message 2 of 5
(3,664 Views)

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

0 Kudos
Message 3 of 5
(3,629 Views)

Ok Brad...You got my attention.

 

Where can I find the DIAdem 2015 BETA version?

Can’t wait !!

0 Kudos
Message 4 of 5
(3,624 Views)

Hello Spidy,

 

You can sign up for the BETA program (at no cost) here:

 

www.ni.com/beta

 

Just follow the instructions for the DIAdem 2015 BETA program.

 

    Otmar

Otmar D. Foehner
0 Kudos
Message 5 of 5
(3,615 Views)