Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Problems with double data type
Message
De
23/03/2002 07:39:29
Hilmar Zonneveld
Independent Consultant
Cochabamba, Bolivie
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00635991
Message ID:
00636418
Vues:
18
>Hi, Hilmar!
>
>>>
>Wouldn't the REPLACE work with double, too?
><<
>
>I don't think so!
>
>The reason because it works with numeric field is: Numeric fields are stored in the DBF as characters (you can see this if you have a look in a DBF using a hex editor).
>Double is stored in an packed format - there is no way to make such tricks without violating the basic rules of storing doubles!
>
>My Conclusion: In your circumstances you can only deal with numeric!

OK, it is time I do some additional tests (I posted the question, because I thought there was a problem - see below - and because I thought that some people had solved it already).

Since I don't want to loose precision (significant digits, that is), I create a table Numeric N(10,0) and Double B(8,0).
replace Numeric with 1e-5
? Numeric && shows 0
? Numeric * 1e6 && shows 0

replace Double with 1e-5
? Double && shows 0
? Double * 1e6 && shows 10, as expected
Further tests: Even the import works as expected! I was fooled in the beginning, because of the display. It seems that "zero decimals" or "four decimals" only affects the display of the data!

In summary:
  • Double seems to be the best choice in this case.
  • There is no real problem in saving data, but there may be confusion in displaying it.

    Thanks for your feedback!

    Hilmar.
    Difference in opinions hath cost many millions of lives: for instance, whether flesh be bread, or bread be flesh; whether whistling be a vice or a virtue; whether it be better to kiss a post, or throw it into the fire... (from Gulliver's Travels)
  • Précédent
    Répondre
    Fil
    Voir

    Click here to load this message in the networking platform