DotNetKick.com is an open-source project. Please report any bugs and let us know your great suggestions. Currently running svn revision 620 (rss)

Kick Spy!, Kick Zeitgeist and Kick Widgets

4
kicks
submitted by codekaizen 4 months, 1 day ago

codeproject.com — A convenient, high-performance money structure for the CLR which handles arithmetic operations, currency types, formatting, and careful distribution and rounding without loss. Also, a look at the various approaches out there for creating a Money type on the CLR.

Add a comment 2 comments | category: | Views: 19 | Get KickIt image code
tags: , , , | tag it

new Add a live kick counter to your blog >> liveImage

You can even customize the image by choosing your own colors, and then clicking the button below to update the preview and the html code:

  • "Kick It" text
  • "Kick It" background
  • kick count text
  • kick count background
  • border

Simply copy and paste this HTML into your blog post.


Users who kicked this story:

Comments:
Main problem with this article is summed up in the extract below:

"In this type, I kept the integral value storage, but opted to represent the fraction as a completely separate Int32, which is scaled by 10^9 (the largest power of 10 which fits into an Int32). [...] Another alternative was to represent the money value with a System.Decimal. The problem with this approach is that System.Decimal is a binary floating-point type, and binary floating-point types give us all sorts of headaches when computing with them and not treating the round-off or computational error accumulation with extreme care."

Um... except System.Decimal *isn't* a floating-point type, it's a scaled integer; from MSDN:

"The binary representation of a Decimal value 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."
posted by gregbeech 4 months, 1 day ago
gregbeech -

You need to read more carefully... it _is_ a floating point type. From the same MSDN page:

"A decimal number is a floating-point value that consists of a sign, a numeric value where each digit in the value ranges from 0 to 9, and a scaling factor that indicates the position of a floating decimal point that separates the integral and fractional parts of the numeric value. "

http://msdn.microsoft.com/en-us/library/system.decimal.aspx
posted by codekaizen 4 months ago



information Login or create an account to comment on this story
 

Sponsored Link: www.carlist.ie

Search:

Ads via The Lounge