Re: Appoximating large numbers



On Thu, 08 Jun 2006 08:18:52 -0400, Bit Twiddler wrote:

"Roy Stogner" <roystgnrNO@xxxxxxxxxxxxxxxxxxx> wrote in message
news:pan.2006.06.08.02.16.53.405175@xxxxxxxxxxxxxxxxxxxxxx

Um, I didn't mean to hit a nerve or anything.

You didn't - if I came across as offended (or even excited), well, it's
hard to convey emotional overtones correctly via text.

Why can't you use floating point numbers? A standard double precision
floating point number will correctly represent the first 15 digits of any
300 digit number, and it'll do so in 64 bits instead of the 3.3 to 8
bits-per-digit that you're currently using. If your software package (and
ideally your CPU) supports quadruple precision floating point, that'll
give you the correct first 30 digits of any 16,000 digit number.

Knowing the first 30 digits of a number as long as 16K digits would
definitely be a step in the right direction!

Thank you very much for your response Roy. I'd appreciate hearing about
the 'obvious' idea that I am missing.

You won't find hardware support for quadruple precision everywhere, but it
looks like you're using an interpreted instead of a compiled language, so
I assume speed isn't an issue and you can use a software implementation. I
don't know what exists for Ruby, but common phrases you can search for to
try to find 128-bit floating point datatypes are "quadruple precision",
"double double", and "long double".

If you can't find anything already existing that works for you, you'll
need to code up your own scientific notation. I'm not familiar with Ruby
so I can't say what would work well - perhaps a BigNum for a mantissa and
a FixNum for an exponent? If you've got so many big numbers that you're
worried about space, however, you may need to use a different programming
language entirely. Ruby seems to do on-the-fly conversions between
fixed and variable length integers, and any language that does that is
probably spending more than a few bytes per number just on overhead.
---
Roy Stogner
.



Relevant Pages

  • Re: Float addition problem / Processor bug?
    ... more low level language like C, where a 'float' is represented by 32/64 ... As far as the "principle of least surprise" is concerned, ... that floating point arithmetic on most systems is in binary and hence ... If Ruby is your *first* language, ...
    (comp.lang.ruby)
  • Re: why still use C?
    ... language guru ) ... > C's features are needed only by a minority, especially in the C standard ... A great many programs make no use of floating point at all, ... switch to produce code using a particular floating point radix; ...
    (comp.lang.c)
  • Re: Underscores in Python numbers
    ... > some arbitrary meaning to it" (to make the language more like Perl ... Dealing with numeric literals with lots of digits is ... numeric literals does it *except* computer language designers. ... Underscore is never used. ...
    (comp.lang.python)
  • Re: Interesting math
    ... Floating point number represents a real number with 6 digits precision. ... Floating point numbers are denoted by the keyword float. ...
    (alt.usage.english)
  • Re: Gentler Decimal Floating-Point
    ... effectively change the radix of a decimal floating point ... under the heading "Logarithms all the time", ... logarithmic representation of numbers to be made workable for all the ... The middle digits are shifted only when the exponent, ...
    (comp.arch.arithmetic)