Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Always Rounding up to the nearest 10

Status
Not open for further replies.

woodyinoz

IS-IT--Management
Jan 8, 2002
215
GB
Hi all,

I am looking to always round a figure up to the nearest 10.
For example: 31 should come out as 40 etc...

I know that round can be used to round to the nearest 10 but I only ever want to round up.
I also know that ceil can be used to round up to the nearest whole number.

Can anyone help me out here?

Thanks,

Woody.
 
var
nn smallint
endVar

nn = 31
nn = (nn/10)*10 + iif(nn.mod(10) > 0, 10, 0)
nn.view()

Padraig
 
Or this

Code:
var
myNum	number
endvar


myNum = 58
myNum = (int(myNum/10)*10)+10

view(myNum)

Mac :)

"There are only 10 kinds of people in this world... those who understand binary and those who don't"

langley_mckelvy@cd4.co.harris.tx.us
 
Scratch my answer, Woody. It doesn't catch it if it is exactly divisble by 10. This one fixes it.

Code:
var
nn	number
endvar


myNum = 51

if myNum.mod(10) <> 0
	then myNum = (int(myNum/10)*10)+10
endif


view(myNum)

Mac :)

&quot;There are only 10 kinds of people in this world... those who understand binary and those who don't&quot;

langley_mckelvy@cd4.co.harris.tx.us
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top