Subject | Re: [IB-Conversions] Importing numeric values - How do you keep number a number? |
---|---|
Author | Helen Borrie |
Post date | 2008-10-27T03:59:48Z |
At 02:02 AM 27/10/2008, you wrote:
If you are *getting* FP data and you want to keep it as FP then store it in a DOUBLE PRECISION column. If you are *getting* integer or fixed numeric data (such as 320, 3.2 or .00032) then store in a NUMERIC or DECIMAL column with sufficient scale and precision to accommodate your largest and smallest numbers.
If you are using the application code to cast the incoming text representations of your numbers then be very careful to cast the numbers appropriately (i.e., using the appropriate AsXxxxx method) before passing them to insert or update statements or to search parameters; otherwise be prepared for unexpected results.
How numbers appear on displays and reports is quite a different issue. Databases don't store visual formats for numbers - that is entirely up to your application. Delphi has default masks for each of its own number types. Your data interface (in this case IBX?) is responsible for casting the SQL data types to the best possible equivalent Delphi type. You use custom masks to make your output fit your display and printing requirements.
Make sure the masks you use for each sort of output are capable of producing a consistent look for the style you want to achieve.
Helen
>I am trying to import numeric values produced by others (analyticalIf you import a number into a number type column then it is a number. If you bring an integer into a column of type FLOAT or DOUBLE PRECISION, e.g. 320, then Firebird stores exactly what the platform's floating type processor calculates as its FP resolution.
>laboratories) into my Firebird (1.5) database. The numeric values can
>cover many orders of magnitude, but generally have 2 significant
>figures. So my values can be values such as 320000, 320, 32, 3.2,
>.00032. I need to be able to reproduce these values in reports (so
>formats like ##.000 are not desirable), use them in calculations, etc.
> I can use a variety of source files TXT,
>CSV, Access, etc. for input.
>
>I have been using a Firebird float field, but many time the values
>such as 3.2 are stored something like 3.1999995678.
>
>How do I keep a number a number?
If you are *getting* FP data and you want to keep it as FP then store it in a DOUBLE PRECISION column. If you are *getting* integer or fixed numeric data (such as 320, 3.2 or .00032) then store in a NUMERIC or DECIMAL column with sufficient scale and precision to accommodate your largest and smallest numbers.
If you are using the application code to cast the incoming text representations of your numbers then be very careful to cast the numbers appropriately (i.e., using the appropriate AsXxxxx method) before passing them to insert or update statements or to search parameters; otherwise be prepared for unexpected results.
How numbers appear on displays and reports is quite a different issue. Databases don't store visual formats for numbers - that is entirely up to your application. Delphi has default masks for each of its own number types. Your data interface (in this case IBX?) is responsible for casting the SQL data types to the best possible equivalent Delphi type. You use custom masks to make your output fit your display and printing requirements.
Make sure the masks you use for each sort of output are capable of producing a consistent look for the style you want to achieve.
Helen