Re: How to Define High-precision Date type



Donkey wrote:
Hi,
The precision of built-in date type of C is very low. Even using long
double float type or double float type, we can only use 12 or 16 digits
after the decimal point. What can we do if we want to use
high-precision number such as the number with 50 digits after the
decimal point. Can we define a user date type?

The average distance from the sun to Earth is about 149.598e6 km. Supose DBL_DIG to be 15. A (1e-15 * sun_to_earth_distance) is about .15 mm.
Be careful is assuming stating that 15 significant digits ("digits after the decimal point" is meaningless) is "very low". When 15 significant decimal digits allows expressing the average distance from the sun to the earth to with 0.15 mm, that is high accuracy, indeed.

The place that greater precision becomes meaningful is in intermendiate results in some arithmetic operations. You might want higher precision in, say, matrix inversion. There are several things to say about this:
1) long double *might* be sufficient, or
2) many packages exist for doing arithmetic with greater precision, or
3) you are making a serious mistake.
Point (3) is significant. If I found my problem required values beyond the capabilities of long doubles (18 significant figures and a range of 1e-4391 to 1e4392 on my implementation), I would seriously consider whether I had pathologogical data or an algorithm that needed fixing.

.



Relevant Pages

  • Re: How to Define High-precision Date type
    ... The precision of built-in date type of C is very low. ... double float type or double float type, we can only use 12 or 16 digits ...
    (comp.lang.c)
  • How to Define High-precision Date type
    ... The precision of built-in date type of C is very low. ... double float type or double float type, we can only use 12 or 16 digits ...
    (comp.lang.c)
  • Re: float bug? perl 5.8, DBI and oracle 10.2.0
    ... precision numbers in oracle, you've got 38 decimal digits to play ... and with minimal coaxing perl will handle them as ... digits from a 32 bit floating point number - I'll go out on a limb ... and hazard that one can expect 12 or so digits from a 64 bit floating ...
    (perl.dbi.users)
  • RE: float bug? perl 5.8, DBI and oracle 10.2.0
    ... I would not characterise 32-bit signed integers as giving 10 digits ... truncate and tell people you get 9 digits of precision. ... perl 5.8, DBI and oracle 10.2.0 ... Floating point values are typically stored in 64 bits or sometimes 96 ...
    (perl.dbi.users)
  • Re: float bug? perl 5.8, DBI and oracle 10.2.0
    ... I would not characterise 32-bit signed integers as giving 10 digits ... truncate and tell people you get 9 digits of precision. ... perl 5.8, DBI and oracle 10.2.0 ... Floating point values are typically stored in 64 bits or sometimes 96 ...
    (perl.dbi.users)