Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / CLR / August 2004

Tip: Looking for answers? Try searching our database.

Decimal: fixed-point or floating-point

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Jon Skeet [C# MVP] - 21 Aug 2004 07:11 GMT
It's been pointed out to me that, contrary to my long-held beliefs, the
documentation for System.Decimal claims that it's a fixed-point data
type. I reckon this is entirely incorrect - it's a floating-point data
type in base 10.

After all, here's another section from the docs:

<quote>
The binary representation of an instance of Decimal consists of a 1-bit
sign, a 96-bit integer number, and a scaling factor used to divide the
96-bit integer and specify what portion of it is a decimal fraction.
The scaling factor is implicitly the number 10, raised to an exponent
ranging from 0 to 28.
</quote>

and here's the FOLDOC definitions of floating-point and fixed-point:
<fixed-point>
The binary representation of an instance of Decimal consists of a 1-bit
sign, a 96-bit integer number, and a scaling factor used to divide the
96-bit integer and specify what portion of it is a decimal fraction.
The scaling factor is implicitly the number 10, raised to an exponent
ranging from 0 to 28.
</fixed-point>

<floating-point>
A number representation consisting of a mantissa, M, an exponent, E,
and an (assumed) radix (or "base") . The number represented is M*R^E
where R is the radix - usually ten but sometimes 2.
</floating-point>

If I'm wrong about this, and decimal really *is* a fixed-point, could
someone post a link to a definition of fixed-point which fits in with
that? Otherwise I'll mail MSDN and let them know that they're talking
rubbish :)

Signature

Jon Skeet - <skeet@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too

Christoph Nahr - 21 Aug 2004 14:07 GMT
That's an interesting subject but you posted the MSDN Decimal docs
twice instead of the FOLDOC fixed-point definition -- could you
repost, please?
Signature

http://www.kynosarges.de

Jon Skeet [C# MVP] - 21 Aug 2004 16:18 GMT
> That's an interesting subject but you posted the MSDN Decimal docs
> twice instead of the FOLDOC fixed-point definition -- could you
> repost, please?

Doh, yes. The FOLDOC fixed-point definition is:

<quote>
A number representation scheme where a number R is represented by an
integer N such that R=N*B, where B is the (assumed) base of the
representation.
</quote>

I don't believe that applies to Decimal, despite the documentation.

Signature

Jon Skeet - <skeet@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too

Christoph Nahr - 21 Aug 2004 17:26 GMT
>I don't believe that applies to Decimal, despite the documentation.

I think you're right. The ECMA standards for C# and the CLI make no
mention of Decimal being a fixed-point format, although they oddly
reserve the term "floating-point" for Single/Double.

The term "fixed-point" only comes up in that one MSDN sentence, and
that's apparently a mistake. Decimal certainly looks like a floating-
point format that can accurately represent decimal fractions.
Signature

http://www.kynosarges.de

Jon Skeet [C# MVP] - 21 Aug 2004 17:59 GMT
> >I don't believe that applies to Decimal, despite the documentation.
>
> I think you're right. The ECMA standards for C# and the CLI make no
> mention of Decimal being a fixed-point format, although they oddly
> reserve the term "floating-point" for Single/Double.

Yes, I noticed that. Very odd.

> The term "fixed-point" only comes up in that one MSDN sentence, and
> that's apparently a mistake. Decimal certainly looks like a floating-
> point format that can accurately represent decimal fractions.

Well I'm glad to know that if I'm going crazy, I'm not the only one :)

I'll try to get some word from MS on this...

Signature

Jon Skeet - <skeet@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too

Chris Taylor - 22 Aug 2004 08:34 GMT
Hi,

Interesting. I believe the .NET definition is also not consistent with
Microsoft's own earlier definition. I believe the .NET decimal
implementation is based on the Oleaut32.dll implementation so I took a look
at the MSDN definition for DECIMAL,  I quote that definition here:

<definition name="DECIMAL" source="MSDN">
A decimal data type that provides a sign and scale for a number (as in
coordinates). Decimal variables are stored as 96-bit (12-byte) unsigned
integers scaled by a variable power of 10. The power of 10 scaling factor
specifies the number of digits to the right of the decimal point, and ranges
from 0 to 28.
</definition>

This seems to be a more reasonable definition?

Cheers

Signature

Chris Taylor
http://dotnetjunkies.com/weblog/chris.taylor

> > >I don't believe that applies to Decimal, despite the documentation.
> >
[quoted text clipped - 11 lines]
>
> I'll try to get some word from MS on this...
Jon Skeet [C# MVP] - 22 Aug 2004 09:16 GMT
> Interesting. I believe the .NET definition is also not consistent with
> Microsoft's own earlier definition. I believe the .NET decimal
[quoted text clipped - 10 lines]
>
> This seems to be a more reasonable definition?

That's equivalent to the one given in System.Decimal though - the bit
that says:

<quote>
The binary representation of an instance of Decimal consists of a 1-bit
sign, a 96-bit integer number, and a scaling factor used to divide the
96-bit integer and specify what portion of it is a decimal fraction.
The scaling factor is implicitly the number 10, raised to an exponent
ranging from 0 to 28.
</quote>

Both of those are fine, I think - it's the calim that it's a fixed-
point type that I have issues with.

Signature

Jon Skeet - <skeet@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too

Jay B. Harlow [MVP - Outlook] - 22 Aug 2004 16:36 GMT
Jon,
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).

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.

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...

Jay

> It's been pointed out to me that, contrary to my long-held beliefs, the
> documentation for System.Decimal claims that it's a fixed-point data
[quoted text clipped - 30 lines]
> that? Otherwise I'll mail MSDN and let them know that they're talking
> rubbish :)
Jon Skeet [C# MVP] - 22 Aug 2004 18:58 GMT
> 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.

Signature

Jon Skeet - <skeet@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too

Jay B. Harlow [MVP - Outlook] - 23 Aug 2004 17:11 GMT
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

> > I agree its confusing.
> >
[quoted text clipped - 48 lines]
> I could be wrong about some of this - I'm currently somewhat shattered
> - but I *think* that's about right.
Jon Skeet [C# MVP] - 23 Aug 2004 17:26 GMT
> Unfortunately I did not explain my self very well :-(
>
[quoted text clipped - 5 lines]
> The reason I consider Decimal fixed point is the lack of normalization with
> the implied 1.

Surely the types would be called "normalised" and "non-normalised" in
that case, wouldn't they? To me, the name suggests the meaning very
closely.

> 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.

It's certainly not an IEEE 754 floating point number - it couldn't be,
as IEEE 754 only specifies binary floating point numbers in the first
place :) I don't know whether there's an IEEE standard for decimal
floating point numbers, and if there is, I don't know if System.Decimal
conforms to it :)

> 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.

No, decimal *isn't* in the fixed-point circle, because its point isn't
fixed. Fixed and floating point are mutually exclusive, IMO. (Note that
FOLDOC includes "Opposite: fixed-point" in its definition of floating-
point.)

> 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.

SQL's numeric is in the fixed-point circle, definitely.

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

But "fixed point like" isn't to do with whether it's a scaled integer
or not - it's to do with whether that scaling factor is fixed (hence
the name) or not. At least, that's how I see it.

Signature

Jon Skeet - <skeet@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too

Jay B. Harlow [MVP - Outlook] - 22 Aug 2004 16:46 GMT
Jon,
Continuing my other post:

If a Decimal is simply a scaled Integer (as opposed to floating point which
would be a scaled "fraction" by my earlier thought).

That might explain (to me at least) how the Decimal class remembers trailing
zeros.

   1000.00 is stored as 100000 e-2.

Just a thought
Jay

> It's been pointed out to me that, contrary to my long-held beliefs, the
> documentation for System.Decimal claims that it's a fixed-point data
[quoted text clipped - 30 lines]
> that? Otherwise I'll mail MSDN and let them know that they're talking
> rubbish :)
Jon Skeet [C# MVP] - 22 Aug 2004 18:58 GMT
> Continuing my other post:
>
> If a Decimal is simply a scaled Integer (as opposed to floating point which
> would be a scaled "fraction" by my earlier thought).

Well, they're both scaled integers from one point of view - it just
depends on how much you scale them by (i.e. whether you include the
size of the mantissa in the exponent or not).

> That might explain (to me at least) how the Decimal class remembers
> trailing zeros.
>
>     1000.00 is stored as 100000 e-2.
>
> Just a thought

The only reason that can't be done in floating binary point (as
specified by IEEE 754) is normalisation, I think - the assumed 1 on the
front of the fraction. I could easily be wrong, however - I'm rather
tired at the minute :(

Signature

Jon Skeet - <skeet@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too

Peter Vervoorn - 23 Aug 2004 16:25 GMT
> If I'm wrong about this, and decimal really *is* a fixed-point, could
> someone post a link to a definition of fixed-point which fits in with
> that? Otherwise I'll mail MSDN and let them know that they're talking
> rubbish :)

It does fit my definition ;)
I always looked at a Decimal as some sort of BCD encoded value, where you
specify the number of digits available behind the decimal point.
(i.e. 5 decimal digits)

With floating point you get an increased accuracy if the integer part
approaches zero.

I hope you understand what I mean, and that I'm not totally wrong with this
:)

Peter
Jon Skeet [C# MVP] - 23 Aug 2004 17:12 GMT
> > If I'm wrong about this, and decimal really *is* a fixed-point, could
> > someone post a link to a definition of fixed-point which fits in with
[quoted text clipped - 5 lines]
> specify the number of digits available behind the decimal point.
> (i.e. 5 decimal digits)

That's exactly what a floating-point value is though. In what way is
the point "fixed" if you specify the number of digits behind the it?

> With floating point you get an increased accuracy if the integer part
> approaches zero.

Could you elaborate? I suspect you're talking about something which is
a byproduct of how binary floating point happens to be implemented, but
isn't fundamental to floating-point itself.

> I hope you understand what I mean, and that I'm not totally wrong with this
> :)

I don't understand exactly what you mean, and I *think* you're still
wrong - but if you could provide any "standard" definitions which
support your point of view, I'm certainly open to being proved wrong :)

Signature

Jon Skeet - <skeet@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too

Peter Vervoorn - 23 Aug 2004 18:40 GMT
>> > If I'm wrong about this, and decimal really *is* a fixed-point, could
>> > someone post a link to a definition of fixed-point which fits in with
[quoted text clipped - 8 lines]
> That's exactly what a floating-point value is though. In what way is
> the point "fixed" if you specify the number of digits behind the it?

If we have 10 positions in total and specify a scale of 4 that leaves 6
digits for the integer part. If the decimal value is 0 (which could be done
with a scale of 0) the point doesn't move, so you still have 6 integer
digits. The position of the point is fixed once it has been set.

Since Decimals are valuetypes the scalingfactor isn't preserved when you
asign a new value, so it is not very usefull I guess.
Decimal a = new Decimal(5,0,0,false,1);
Decimal b = new Decimal(5,0,0,false,1);
Decimal c = new Decimal(0,0,0,false,1);
c = Decimal.Multiply(a, b);
c's value is now 0.25 which should not have been possible, it should have
been 0.2 or 0.3 because we have set the fixed nr of decimals in the
constructor. (IMHO of course.)

>> With floating point you get an increased accuracy if the integer part
>> approaches zero.
>
> Could you elaborate? I suspect you're talking about something which is
> a byproduct of how binary floating point happens to be implemented, but
> isn't fundamental to floating-point itself.

If we have only 4 bits available, and want to write 1.5 that could be:
1100 3 (1*2^0 + 1*2^-1 + 0*2^-2 + 0*2^-3 = 1 + 0.5 + 0 + 0)
3 specifies the location of the 2^0 bit.
This leaves 3 bits for creating the decimal part consisting combinations of
1/2 + 1/4 + 1/8.

7.5 that could be:
1111 1 (1*2^2 + 1*2^1 + 1*2^0 + 1*2^-1 = 4 + 2 + 1 + 0.5 = 7.5)
We can only specify 0 or 0.5 for the decimal part here, we only have 1 bit
(2^-1) available.

>> I hope you understand what I mean, and that I'm not totally wrong with
>> this
[quoted text clipped - 3 lines]
> wrong - but if you could provide any "standard" definitions which
> support your point of view, I'm certainly open to being proved wrong :)
Jon Skeet [C# MVP] - 23 Aug 2004 19:33 GMT
> >> It does fit my definition ;)
> >> I always looked at a Decimal as some sort of BCD encoded value, where you
[quoted text clipped - 8 lines]
> with a scale of 0) the point doesn't move, so you still have 6 integer
> digits. The position of the point is fixed once it has been set.

But it's not set by the type itself, it's set by the value. It's
floating in that it can appear in different places depending on the
value.

Besides, the same is basically true for binary floating point, isn't
it? Once the exponent is set, that defines how many bits are before the
binary point and how many are after it.

> Since Decimals are valuetypes the scalingfactor isn't preserved when you
> asign a new value, so it is not very usefull I guess.
[quoted text clipped - 5 lines]
> been 0.2 or 0.3 because we have set the fixed nr of decimals in the
> constructor. (IMHO of course.)

Whereas IMO we fixed the number of decimals for the two numbers we
created, not the result of the multiplication.

> >> With floating point you get an increased accuracy if the integer part
> >> approaches zero.
[quoted text clipped - 13 lines]
> We can only specify 0 or 0.5 for the decimal part here, we only have 1 bit
> (2^-1) available.

So by "the integer part" here, do you mean "the bit before the decimal
point" rather than "the mantissa"? If so, that's true for decimals as
well. If you've got 15000.something you get fewer decimal digits to
play with for the "something" than if you've got 15.something.

Signature

Jon Skeet - <skeet@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too

Peter Vervoorn - 24 Aug 2004 00:26 GMT
> But it's not set by the type itself, it's set by the value. It's
> floating in that it can appear in different places depending on the
[quoted text clipped - 3 lines]
> it? Once the exponent is set, that defines how many bits are before the
> binary point and how many are after it.

I always assumed fixed point meant that you set the scale once and then all
values assigned to that variable will use that scale, and floating point
meant the scale was set each time a value was assigned.

This document seems to support this:
"Fixed-point has a fixed window of representation, which limits it from
representing very large or very small numbers. Also, fixed-point is prone to
a loss of precision when two large numbers are divided. Floating-point, on
the other hand, employs a sort of "sliding window" of precision appropriate
to the scale of the number. This allows it to represent numbers from
1,000,000,000,000 to 0.0000000000000001 with ease." (from:
http://research.microsoft.com/~hollasch/cgindex/coding/ieeefloat.html )

> Whereas IMO we fixed the number of decimals for the two numbers we
> created, not the result of the multiplication.

True.
However, my point was that I would like to specify the scale of a variable
and as long as the variable is in scope it keeps that same scale, whatever
the value assigned to it.
Since Decimal is a valuetype this is not possible.

Regards,

Peter
Jon Skeet [C# MVP] - 24 Aug 2004 03:03 GMT
> > But it's not set by the type itself, it's set by the value. It's
> > floating in that it can appear in different places depending on the
[quoted text clipped - 7 lines]
> values assigned to that variable will use that scale, and floating point
> meant the scale was set each time a value was assigned.

That's a very specific idea of fixed-point which would only apply to
variables, rather than values themselves.

It's slightly wider than that: the idea of fixed-point is that you set
the scale once and then all values *of that type* will use that scale.

Floating point does indeed mean that the scale is set in each value. I
don't think the concept of assignment and variables comes into this at
all though.

> This document seems to support this:
> "Fixed-point has a fixed window of representation, which limits it from
[quoted text clipped - 4 lines]
> 1,000,000,000,000 to 0.0000000000000001 with ease." (from:
> http://research.microsoft.com/~hollasch/cgindex/coding/ieeefloat.html )

I don't see how that supports what you were saying, to be honest.

> > Whereas IMO we fixed the number of decimals for the two numbers we
> > created, not the result of the multiplication.
[quoted text clipped - 4 lines]
> the value assigned to it.
> Since Decimal is a valuetype this is not possible.

It wouldn't be possible if Decimal were a reference type, either -
assigning a different value to the variable would do exactly that. With
either reference types or value types you could create a type so that
multiplying one value by another always resulted in a value which used
(say) the maximum of the scales of each of the values. That's not what
happens though, and I think that would be a fairly odd type, to be
honest.

I'm now unclear whether you still think decimal is fixed-point or
not...

Signature

Jon Skeet - <skeet@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too

Peter Vervoorn - 24 Aug 2004 12:29 GMT
>> > But it's not set by the type itself, it's set by the value. It's
>> > floating in that it can appear in different places depending on the
[quoted text clipped - 14 lines]
> It's slightly wider than that: the idea of fixed-point is that you set
> the scale once and then all values *of that type* will use that scale.

That's a very specific idea too ;)
Where would you set the scale?

> Floating point does indeed mean that the scale is set in each value. I
> don't think the concept of assignment and variables comes into this at
[quoted text clipped - 13 lines]
>
> I don't see how that supports what you were saying, to be honest.

When the scale is set, the window is fixed and you can only represent a
part of all the possible values.

> I'm now unclear whether you still think decimal is fixed-point or
> not...

I guess it is floating, because it is not fixed in the defintion of Decimal,
and you can't specify the scaling yourself anywhere.

Peter
Jon Skeet [C# MVP] - 24 Aug 2004 12:57 GMT
> > That's a very specific idea of fixed-point which would only apply to
> > variables, rather than values themselves.
[quoted text clipped - 3 lines]
>
> That's a very specific idea too ;)

Well, it has wider application than one which requires

> Where would you set the scale?

In the type itself, where everything else is set. So just as
System.Double defines there to be 52 bits of mantissa, 11 bits of scale
and 1 bit of sign, you could have a fixed binary point type which had
63 bits of mantissa, 1 bit of sign, and a scale which was always (say)
512. Instead of using 11 bits to represent the scale, they'd be extra
precision, at the cost of range. You'd always have the same number of
bits before the binary point (even if some were zero) and the same
number of bits after the binary point (even if some were zero).

Just to make this all a bit more concrete, here's a simple fixed-point
type:

using System;

/// <summary>
/// Fixed point type which always has two decimal places.
/// </summary>
class FixedPoint
{
   int unscaled;
   
   public FixedPoint (int unscaled)
   {
       this.unscaled = unscaled;
   }

   public static FixedPoint operator *(FixedPoint x, FixedPoint y)
   {
       long a = (long)x.unscaled * (long)y.unscaled;
       return new FixedPoint ((int)(a/100));
   }

   public static FixedPoint operator +(FixedPoint x, FixedPoint y)
   {
       return new FixedPoint (x.unscaled+y.unscaled);
   }

   // In real life you'd define other operators here, of course
   
   public override string ToString()
   {
       int abs = Math.Abs(unscaled);
       return String.Format("{0}{1}.{2:d2}",
                            unscaled < 0 ? "-" : "",
                            abs/100,
                            abs%100);
   }
}

class Test
{
   static void Main()
   {
       FixedPoint two = new FixedPoint(200);

       FixedPoint twoPointFive = new FixedPoint(250);
       
       Console.WriteLine (two+twoPointFive);
       Console.WriteLine (two*twoPointFive);
   }
}

Here the scale is fixed at 1/100. In other words, the actual value is
the unscaled value divided by 100. The fact that it's not divided by
something which is specified in the value is what makes this type fixed
point rather than floating point.

> >> This document seems to support this:
> >> "Fixed-point has a fixed window of representation, which limits it from
[quoted text clipped - 12 lines]
> When the scale is set, the window is fixed and you can only represent a
> part of all the possible values.

But the scale is just as "set" in a System.Double... You were using
that quote to support this quote:

<quote>
I always assumed fixed point meant that you set the scale once and then
all values assigned to that variable will use that scale, and floating
point meant the scale was set each time a value was assigned.
</quote>

The quote from the web page doesn't support that as it doesn't mention
variables at all.

> > I'm now unclear whether you still think decimal is fixed-point or
> > not...
>
> I guess it is floating, because it is not fixed in the defintion of Decimal,
> and you can't specify the scaling yourself anywhere.

Well, you specify the scale when you create the instance - either
implicitly or explicitly. Exactly the same is true with System.Single
or System.Double, except they don't provide constructors to separate
out the parts like System.Decimal does.

Signature

Jon Skeet - <skeet@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too

Peter Vervoorn - 24 Aug 2004 15:59 GMT
>> Where would you set the scale?
>
> In the type itself, where everything else is set.

This is the source of the difference, when it is defined inside the type
somebody who is using the type cannot set it either implicit or explicit.
If this is a requirement for fixed point types then Decimal is floating
point (in that case my definition for fixed point was wrong).

Regards,

Peter
Jon Skeet [C# MVP] - 24 Aug 2004 16:51 GMT
> >> Where would you set the scale?
> >
> > In the type itself, where everything else is set.
>
> This is the source of the difference, when it is defined inside the type
> somebody who is using the type cannot set it either implicit or explicit.

Indeed.

> If this is a requirement for fixed point types then Decimal is floating
> point (in that case my definition for fixed point was wrong).

That's certainly my understanding of fixed point types.

Signature

Jon Skeet - <skeet@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too


Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.