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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Round to nearest thousand

Status
Not open for further replies.

kayek

Programmer
Jun 19, 2003
95
US
How do you round a number to the nearest thousand.

For Example:
round 96,452 to 96,000
round 96,500 to 97,000
 
To avoid the "bank rounding" behaviour of the Round function:
1000*((yourNumber+500)\1000)

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
PHV,

I thought you had to convert the number to integer before multiplying.

1000*clng((yourNumber+500)\1000)
 
stix4t2:
1000*((yourNumber+500)[!]\[/!]1000)
The result of an integral division is already integral ...

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top