Re: rounding a number...

 BBS: Inland Empire Archive
Date: 02-06-93 (20:50)             Number: 320
From: DAVID WANG                   Refer#: NONE
  To: CHRIS TRACY                   Recvd: NO  
Subj: Re: rounding a number...       Conf: (2) Quik_Bas
On 02-02-93  16:21 Chris Tracy declared "rounding a number..." to All...

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

Num = INT(Num * Places2RoundRaised2_10 + .5) / Places2RoundRaised2_10

Something I actually learned from an Apple (amazing!)
To, say, round to 10ths Places2RoundRaised2_10 would be 10, hundredths, 100...

Be warned, though.  This method is about 8 TIMES as slow as CINT, but it
does round to specific digits.

--- Blue Wave/RA v2.10 [NR]
 * Origin: Hard Disc Cafe / Houston Texas / (713) 589-2690 / (1:106/30.0)
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