Re: Price Data Formatting
- From: "Webbiz" <noreply@xxxxxxx>
- Date: Tue, 19 Aug 2008 15:09:48 -0500
Mike,
When you load in a datafile of a stock or commodity, you get data like this
for example:
1.2324
1.2345
1.234
1.2876
1.2865
....
Now, when I said 'MOSTLY', is that if you look at this data, note that MOST
have 4 digits following the decimal point.
What if I only sampled one of these and it happened to be the third one down
on that list? I'd end up with a 'pattern' for all my displayed data that was
only 3 digits following the decimal rather than 4. Yet there is nothing
wrong with the 3rd number in this dataset. It just happens to end with a
zero value (and thus is not present).
So a 'sampling' is needed to note that MOST of the data use 4 digits
following the decimal.
Make sense?
So when I display prices in my application, I want to use the SAME format as
the data loaded. That is, 4 digits right of the decimal.
Right now, without any formatting, I get values that look like this after a
calculation:
1.2837463839834874
1. It doesn't fit well in my textboxes for display.
2. It simply does not look like the prices loaded.
So the above should be shown as 1.2837 to match the format of the data
loaded.
Thanks.
Webbiz
"Mike Williams" <mikea@xxxxxxxxxxxxxxxxx> wrote in message
news:eJlGr%23iAJHA.4368@xxxxxxxxxxxxxxxxxxxxxxx
"Webbiz" <noreply@xxxxxxx> wrote in message
news:ewH%23BUiAJHA.3952@xxxxxxxxxxxxxxxxxxxxxxx
Hi Mike. Thanks for your comments. Yes, I understand how
the Format() function works. The exercise here, however, is
that the data format is NOT KNOWN during design time but is based on the
format of the data loaded during runtime.
The thing is you have not yet given us sufficient information about what
you are doing. For example, in what format is the data as you are loading
it in. Is it being loaded as a floating point value (Single or Double or
whatever) is is it being loaded as a formatted string? Perhaps if you post
a snippet oif code showing where you are loading this data from and
exactly how you are loading it we might be in a better position to help.
Another example of where more information is needed is regarding your
statement when you said, "For example, if the program loads in data that
appears to be 'MOSTLY' one digit to the left of the decimal and 3 to the
right, I want all numbers that result from any calculations on this data
to also be in the same format [with three decimal places]". Do you really
mean that? It sounds a bit odd to me. For example, suppose you test a set
of incoming data and you discover that 10 values have two decimal places
and 48 values have three decimal places and 32 values have four decimal
places. In this cases the data MOSTLY has three decimal places. Do you
REALLY want to truncate ALL displayed values so that they all have three
decimal places, missing off the fourth decimal digit from the 32 values
that originally had four digits? It does not sound at all like the right
thing to do if you want my opinion. In the specific example I have just
described I would personally show all values to four decimal places. In
other words, perhaps you should be looking for the MAXIMUM number of
decimal digits in the data items, ignoring "odd balls" that have a lot
more than the average (such as the odd 1.2344999999989 that might creep in
somewhere).
The other thing we have asked that you haven't yet provided an answer to
is *where are you displaying the resultant output*. This is VERY
important, as we cannot give much useful advice unless we know how you are
displaying it. For example, are you printing the ouput using Print
statements (perhaps to a Form or a PictureBox or a Printer) or are you
placing it in some sort of control, such as a TextBox or a ListBox?
Perhaps you woud like to answer that question?
My advice, regardless of where you are displaying the data, is to display
it in such a way that the decimal point is set in a fixed position and the
"whole part" of the number is displayed right aligned to the left of the
decimal point with the decimal part displayed left aligned to the right of
it, and with sufficient trailing zeros to accommodate however many decimal
digits you have decided to display. But the best method of doing this will
vary greatly, depending on your output device and the font you wish to
use, which you haven't yet told us about.
Mike
.
- Follow-Ups:
- Re: Price Data Formatting
- From: Mike Williams
- Re: Price Data Formatting
- References:
- Price Data Formatting
- From: Webbiz
- Re: Price Data Formatting
- From: Mike Williams
- Re: Price Data Formatting
- From: Webbiz
- Re: Price Data Formatting
- From: Mike Williams
- Price Data Formatting
- Prev by Date: Re: Windows 2003 & SrvAny.exe
- Next by Date: Re: VB6 and Beyond
- Previous by thread: Re: Price Data Formatting
- Next by thread: Re: Price Data Formatting
- Index(es):
Relevant Pages
|