Re: Single and double data types

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance

From: Dave Neve (NoAdressForSpammers_at_Nofs.fr)
Date: 08/01/04


Date: Sun, 1 Aug 2004 19:35:02 +0200

Hi

Thanks for the maths lesson.

But what about this gap then. How can you use singles and doubles data types
especially if the user is going to assign variables like in a calculator
program.

The result of the calculation could fall into the gap.

Would the program round off, cite an unhandled exception or just crash?

Regards

Dave Neve
"Jay Freedman" <jay.freedman@verizon.net> a écrit dans le message de news:
h62qg0pd7cgf6oc6lfgmpikc2k1p45hi5d@4ax.com...
> Hi Dave,
>
> A negative exponent means "divide 1 by the base (10) to the positive
> exponent", for example,
>
> 10 to the power of -2 = 1/(10 to the power of 2) = 1/100 = 0.01
>
> You can also think of exponents of 10 as "moving the decimal point",
> to the right if positive or to the left if negative. For example,
>
> 3.14E2 = 314
> 3.14E-2 = 0.0314
>
> You're correct, there is a gap between zero and the smallest positive
> number that can be represented as a single or double data type.
> There's an equal gap between zero and the smallest negative number
> that can be represented by a single or a double. This gap is purely a
> result of the limited number of bits used to store the number in the
> computer's memory, and not true for real numbers. The gap is less for
> doubles than for singles, because doubles can store more digits.
>
> In digital storage as in real numbers, there is only one zero and it
> is neither positive nor negative.
>
> By the way, I give you credit for asking. Lots of people would just
> shrug and say "that's the way it is".
>
> --
> Regards,
> Jay Freedman http://aspnet2.com/mvp.ashx?JayFreedman
> Microsoft Word MVP FAQ: http://www.mvps.org/word
>
> "Dave Neve" <NoAdressForSpammers@Nofs.fr> wrote:
>
> >Hi
> >
> >I have a theoretical question on this subject but I'm naff at maths so
don't
> >laugh.
> >
> >From a book, I can see that the lower and upper limits of a single data
type
> >is
> >
> >-3.402823E38 to - 1.401298E-45 for negative values
> >1.401298E-45 to 3.402823E38 for positive values
> >
> >I don't even know how to do calculations with exponents on my computer to
> >check for myself but what I'd like to know is
> >
> >a How do - exponents work
> >
> >eg 10 to the power of 2 = 100
> > 10 to the power of -2 = ?
> >
> >b Do the limits of a single or double data type leave a 'gap' in
between?
> >
> >ie A short data type (-32,768 to 32767) can clearly handle any figure in
> >between but this isn't so clear for me with regards to floating point
data
> >types where there seems to be a gap.
> >
> >Why not -0.000000 and 0.000000 or sth similar?
> >
> >Thanks and remember what Einstein4S Maths teacher said about him when he
was
> >16 (ok I ain't 16 anymore but...)
> >
> >
> >Dave Neve
> >
> >
>