## Working with Signed Non-Decimal and Bitwise Values [Ron Petrusha]

Recently, a number of questions have surfaced about the accuracy of the .NET Framework when working with the binary representation of numbers. (For example, see https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=295117.) The issue surfaces most clearly when we convert the hexadecimal or octal string representation of a numeric value that should be out of range of its target data type…

## Decimal Negative Zero Representation [Lakshan Fernando]

One of our customers wondered recently if we represent negative zero in Decimal. At first glance, it doesn’t look to be the case as seen below;    Decimal zero = Decimal.Zero;   Decimal negativeZero_1 = new Decimal(0, 0, 0, true, 0);   Decimal negativeZero_2 = -0.0m;    Decimal negativeZero_3 = Decimal.Negate(Decimal.Zero);   Console.WriteLine(“Negative Zero: {0}, {1}, {2} Positive Zero: {3}”, negativeZero_1, negativeZero_2, negativeZero_3,…

## Arbitrary length Integer/Arbitrary precision Double Classes [Ari Weinstein]

Another set of functionality we may want to add in Orcas are classes which can be an integer of arbitrary length, and a double of arbitrary precision (which could essentially be the arbitrary length integer with a decimal offset).  Aside from this type itself, we are interested in what related functionality you would be looking…

## Why does Double.Parse(Double.MaxValue.ToString()) not work? [Anthony Moore]

System.Double and System.Single are have inexact precision of decimal digits because internally they are a floating point binary number. As such, beyond a certain number of significant digits, their decimal representation becomes approximate. The standard Double.ToString() and Single.ToString() thus are not guaranteed to round-trip back to the same value if you call Parse or TryParse….

## How Did System.Decimal Change from V1.0 to V1.1? [Anthony Moore]

There were very few noticeable changes between the V1.0 and the V1.1 release. One change that people sometimes notice is that Decimal looks different across the two versions. The changes are largely cosmetic, although in some rare cases applications have been affected.   Decimal was revised to comply with a late update to the CLI,…

## New Format on the Block [Anthony Moore]

One thing that has not changed much in Whidbey is the set of format strings used by base data types for parsing and formatting. However, there is one new format element supported by the DateTime class that can be very useful if you use the ParseExact method to parse XML.   There is a new…

## How to Work Around Problems Serializing DateTime in XML [Anthony Moore]

I wrote a while ago about problems with the way DateTime worked with features like DataSet, XML Serialization (WebServices) and XmlConvert. Basically, DateTime is always treated as a local time by these XML-based systems, which means that you get incorrect results if you use UTC or whole dates with them. What makes this worse is…

## DateTime Parsing and Formatting with Time Zones [Anthony Moore]

Here is a new DateTim FAQ entry. What is the relationship between DateTime parsing and formatting and the time zone? Before reading below, see this entry for a more practical description of how to using formatting and parsing for the purposes of storing dates and times, which is where you are most likely to have…

## A short note about Buffer.BlockCopy [Gang Peng]

Buffer.BlockCopy has following signature: public static void BlockCopy(Array src,  int srcOffset,  Array dst,  int dstOffset,  int count);   It copies count bytes from src, beginning at srcOffset, to dst, beginning at dstOffset. srcOffset is the byte offset into src and dstOffset is the byte offset into dst.   Buffer.BlockCopy only supports array of primitive types…

## Dead C Hacks: Reallocating or Changing an object’s type in place in .NET? [Brian Grunkemeyer]

I was recently asked if there was a way to reallocate an object on top of another one, or to change the type of an object at runtime. This must have been a somewhat common practice in native C or C++ programs, perhaps something that C++’s placement new facilitated. I’m not a big fan of the…