WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

Math Related UDFs

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

; This UDF will round a number to a specified number of significant digits
; e.g.  sigr(12783,2) becomes 13000

#DefineFunction sigr(value,sigfigs)    ; round to desired number of significant digits
   e=sigfigs-(1+Int(Log10(Abs(value)))); compute power of 10 needed
   multdiv= 10.0**e                    ; create the E notation number
   ret= Int(value*multdiv)/multdiv     ; adjust, simple round, unadjust
   Return(Int(ret))                    ; ta-da
#EndFunction

zz=12783
xx=sigr(zz,2)
Message("",xx)



Article ID:   W16739
File Created: 2005:02:18:12:22:08
Last Updated: 2005:02:18:12:22:08