vol = Decimal.Round(exposure.Volatility, 5);
This won't let me round
exposure.Volatility
to a decimal b/c it say's conversion from decimal? to decimal cannot take place.
How do I round that number to 5 decimal places? It's a nullable decimal.
Assuming a null value is equal to zero in this circumstance, something like:
vol = exposure.Volatility.HasValue ? Decimal.Round(exposure.Volatility.Value, 5) : 0;
If "vol" is also nullable then do:
vol = exposure.Volatility.HasValue ? Decimal.Round(exposure.Volatility.Value, 5) : null;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With