BBS: Inland Empire Archive Date: 02-05-93 (02:05) Number: 361 From: DIK COATES Refer#: NONE To: CHRIS TRACY Recvd: NO Subj: rounding a number... Conf: (2) Quik_Bas
>>>> QUOTING Chris Tracy to All <<<< If you're looking for something to print a string formatted to the correct number of decimal places, but retaining the original number then consider the following... '****************************************************** FUNCTION FSINGLE2STR$ ' ' Procedure returns a formatted string variable from a floating point ' (single) variable. The variable can be a SINGLE defined in a TYPE ' variable. ' ' CALL: FSINGLE2STR$(float!, format$) ' ' ARG: float! - floating point variable to be converted to string ' format$ - format required using PRINT USING format ' ' RET: string ' ' USES: TRIM$() ' ' COMP: MS Basic 7.1 ' ' REV: 92-02-01 ' '**************************************************************************** ' FUNCTION FSINGLE2STR$ (float!, format$) filenum% = FREEFILE OPEN "\DEV\NUL" FOR RANDOM AS #filenum% LEN = 15 FIELD #filenum%, 15 AS temp$ LSET temp$ = "" PRINT #filenum%, USING format$; float!; FSINGLE2STR$ = TRIM$(temp$) CLOSE #filenum% END FUNCTION' FSINGLE2STR$() and TRIM$() is just something like RTRIM$(LTRIM$(a$)) Regards Dik, Oshawa, Canada ___ Blue Wave/QWK v2.10 --- Maximus 2.00 * Origin: Durham Systems (ONLINE!) (1:229/110)
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