rounding a number...

 BBS: Inland Empire Archive
Date: 02-05-93 (11:29)             Number: 376
From: RICK PEDLEY                  Refer#: NONE
  To: CHRIS TRACY                   Recvd: NO  
Subj: rounding a number...           Conf: (2) Quik_Bas
 On 02-02-93 Chris Tracy wrote to All...

 CT> Does anyone know if there is a routine to actually round a
 CT> number for real to a certain decimal place? like 3.1415
 CT> (hehe) would become 3.142? or something like that.... or
 CT> have it round up or down... etc... you get the picture.. i
 CT> know INT just kills all the number after it, but thats not
 CT> really what i was looking for...

NumPlaces = 3
RealNum! = 3.1415
RealNum! = INT(RealNum! * 10 ^ NumPlaces + .5)/ 10 ^ NumPlaces

Work through a couple of examples and you'll see what it's doing.


... OFFLINE 1.43 * Network management is like herding cats.

--- Maximus 2.01wb
 * Origin: The BULLpen BBS * Intel 14.4EX (613)549-5168 (1:249/140)
Outer Court
Echo Basic Postings

Books at Amazon:

Back to BASIC: The History, Corruption, and Future of the Language

Hackers: Heroes of the Computer Revolution (including Tiny BASIC)

Go to: The Story of the Math Majors, Bridge Players, Engineers, Chess Wizards, Scientists and Iconoclasts who were the Hero Programmers of the Software Revolution

The Advent of the Algorithm: The Idea that Rules the World

Moths in the Machine: The Power and Perils of Programming

Mastering Visual Basic .NET