Determine if a decimal can be stored as int32
Posted
by anchandra
on Stack Overflow
See other posts from Stack Overflow
or by anchandra
Published on 2010-04-29T15:26:38Z
Indexed on
2010/04/29
15:37 UTC
Read the original article
Hit count: 240
I am doing some custom serializing, and in order to save some space, i want to serialize the decimals as int, if possible value wise. Performance is a concern, since i am dealing with a high volume of data. The current method i use is:
if ((value > Int32.MinValue) && (value < Int32.MaxValue) && ((valueAsInt = Decimal.ToInt32(value)) == value))
{
return true;
}
Can this be improved?
© Stack Overflow or respective owner