Great. Thankyou all!
------------------
Kind Regards
Mike
Announcement
Collapse
No announcement yet.
Decimal Places written to file
Collapse
X
-
PB Format$ in NOT exactly like VB's
I believe that Format$ does round
From PB HELP
Code:Value Fmt String Output 0.2 "" .200000002980232 (no leading spaces) 0.2# "" .2 (no leading spaces) 0.468 ##.## 0.47 (1 leading space) 0.468 #.#### 0.4680 (no leading spaces)
Joe Murphy
------------------
Leave a comment:
-
Remember that STR$ always leaves a leading chr$(32) for positive
numbers, so the appropriate method would be to write the
format$ which converts to string but doesn't have the
leading chr$(32)
------------------
-Greg
Leave a comment:
-
I guess you could even try the built-in PB function ROUND.
x = ROUND(numeric expression, n)
where n is the number of decimal places that you what to round
to. Then just WRITE the STR$(x) to the file.
------------------
Paul Squires
mailto:[email protected][email protected]</A>
Leave a comment:
-
Mike,
WRITE# hfile2,Date,Time,format$(openprice+.005,"#######.##") _
format$(highprice+.005,"#######.##"),format$(lowprice+.005,"#######.##) _
format$(closeprice+.005,"#######.##")
Leave the +.005 off if you don't want to round to the
nearest cent.
Phil
------------------
E-Mail: [email protected]
Leave a comment:
-
You might declare your ????Price variables as Extended Currency (@@).
------------------
Bernard Ertl
Leave a comment:
-
Decimal Places written to file
I am writing a number of variables to file with:
WRITE# hFile2, Date, Time, OpenPrice, HighPrice, LowPrice, ClosePrice
In the file I get varying lengths of decmal places no matter what I do (Rounding etc) ie:
991210,952,1431.5,1432.5,1430.5,1432.5
991210,954,1432.30004882812,1432.30004882812,1431.30004882812,1431.30004882812
991210,956,1431.09997558594,1431.09997558594,1429.19995117188,1429.5
991210,958,1429.69995117188,1432,1429.5,1431.80004882812
991210,1000,1431.69995117188,1433,1431,1433
991210,1002,1432.5,1433,1432,1432.5
How can get the number of decimal places I want (2)?
------------------
Kind Regards
MikeTags: None
Leave a comment: