Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Comparison of C Sharp and Java
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
===== High-precision decimal numbers ===== C# has a type and literal notation for high-precision (28 decimal digits) decimal arithmetic that is appropriate for financial and monetary calculations.<ref>{{cite web |title=decimal |url=http://msdn.microsoft.com/en-us/library/364x0z75(v=vs.110).aspx | work=C# Reference |date=19 August 2012 |publisher=Microsoft}}</ref><ref name="thedecimaltype"/><ref>{{cite book | last=Mok | first=Heng Ngee |title=From Java to C? : a developer's guide |year=2003 |publisher=Addison-Wesley|location=Harlow, England | isbn=978-0-321-13622-0 | chapter=9.5. The decimal type}}</ref> Contrary to the {{mono|float}} and {{mono|double}} data types, decimal fractional numbers such as 0.1 can be represented exactly in the decimal representation. In the float and double representations, such numbers often have non-terminating binary expansions, making those representations more prone to round-off errors.<ref name=thedecimaltype>{{cite book | last=Sestoft | first=Jon Jagger, Nigel Perry, Peter |title=C? annotated standard |year=2007 |publisher=Elsevier/Morgan Kaufmann Publishers | location=Amsterdam | isbn=978-0-12-372511-0 | chapter=11.1.7 The decimal type}}</ref> While Java lacks such a built-in type, the Java library does feature an ''arbitrary precision'' decimal type. This is not considered a language type and it does not support the usual arithmetic operators; rather it is a reference type that must be manipulated using the type methods. See more about arbitrary-size/precision numbers [[#Advanced numeric types|below]].
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)