Re: Decimal: fixed-point or floating-point

From: Jay B. Harlow [MVP - Outlook] (Jay_Harlow_MVP_at_msn.com)
Date: 08/23/04


Date: Mon, 23 Aug 2004 11:11:04 -0500

Jon,
Unfortunately I did not explain my self very well :-(

Unfortunately I do not know how to explain it better. :-((

The reason I consider Single & Double floating point is the normalization
with the implied 1.

The reason I consider Decimal fixed point is the lack of normalization with
the implied 1.

Note I also consider Decimal a floating point number for the reason you
gave, I hope you agree its just not an IEEE floating point number.

I see it as overlapping circles where Single & Double are in the floating
point circle & the IEEE floating point circle, where are System.Decimal is
in the floating point circle & the fixed point circle. While Integer is only
in the fixed point circle. Note, I consider SQL's numeric to be in a circle
very similar to Decimal's circles but definitely not floating point.

Maybe it would be more accurate to state I consider Decimal a scaled
Integer. Ergo fixed point like.

Jay

"Jon Skeet [C# MVP]" <skeet@pobox.com> wrote in message
news:MPG.1b92e4ef6d28785b98b24f@msnews.microsoft.com...
> Jay B. Harlow [MVP - Outlook] <Jay_Harlow_MVP@msn.com> wrote:
> > I agree its confusing.
> >
> > I thought floating point numbers (Single/Double) have the entire number
to
> > the right of the decimal point (1.xyz) with an implied 1 where as fixed
> > point (Decimal) has the entire number to the left of the decimal point
> > (xyz.) (ala Integer).
>
> No, floating-point just means that the location of the point is
> specified by the value, whereas fixed-point means that the scaling
> factor is specified by the type itself. For instance, you could have a
> fixed-point representation which *always* has exactly two digits to the
> right of the decimal point.
>
> Indeed, this is how the Numeric type in SQL works - you specify the
> scale and the precision of the number when defining the column, and you
> always know how many decimal places there will be.
>
> > For example the number 123 is:
> >
> > 1.23 E2 in (base 10) floating point, while its 123 E0 in decimal
> >
> > Basically its how the scale is represented.
>
> That's just a bias though - work out how long the mantissa is, add or
> subtract the appropriate number of powers, and there's no difference.
>
> Imagine that all decimal numbers were of the form
>
> 0.xxx
>
> and that the scaling factor is the same minus 28 or 29. That might
> work. I think. Possibly they *are* fundamentally different - but I
> think they're both *floating* point because the position of the point
> is specified by the value rather than the type itself.
>
> > I thought Decimal was Fixed point because the decimal point is all the
way
> > on the right just like Integer. Then that number is scaled.
> >
> > If that made any sense...
>
> Binary floating point is exactly the same as that though - you take a
> binary integer, optionally (depending on other things) add a leading 1,
> and then scale it by an amount specified by the exponent part.
>
> The Decimal type admittedly doesn't have the leading digit implied
> (because it can't), but they're the same principal otherwise, just with
> a different base and with different ranges of values. (Decimal also
> doesn't have the various things like NaN, infinity, denormal/subnormal,
> but that's a different matter.)
>
> I could be wrong about some of this - I'm currently somewhat shattered
> - but I *think* that's about right.
>
> --
> Jon Skeet - <skeet@pobox.com>
> http://www.pobox.com/~skeet
> If replying to the group, please do not mail me too



Relevant Pages

  • Re: Decimal: fixed-point or floating-point
    ... > The reason I consider Single & Double floating point is the normalization ... It's certainly not an IEEE 754 floating point number - it couldn't be, ... > point circle & the IEEE floating point circle, ...
    (microsoft.public.dotnet.framework.clr)
  • Re: Float comparison
    ... the floating point object doesn't specify a range. ... to store a value, but only one value at a time. ... You just attempted to specify the programming. ...
    (comp.lang.c)
  • Re: Float comparison
    ... the floating point object doesn't specify a range. ... You just attempted to specify the programming. ... are having trouble understanding it. ...
    (comp.lang.c)
  • Re: Decimal: fixed-point or floating-point
    ... > I thought floating point numbers have the entire number to ... this is how the Numeric type in SQL works - you specify the ... > Basically its how the scale is represented. ... Binary floating point is exactly the same as that though - you take a ...
    (microsoft.public.dotnet.framework.clr)
  • Re: Avoiding floating points
    ... "Add Fixed and Floating Decimal Point Numbers to Delphi" ... fraction numbers. ... And if you do allow for rounding the result into a ... then you need to specify or know what ...
    (borland.public.delphi.non-technical)