开发者

C#: Multiply Decimal with Float?

开发者 https://www.devze.com 2023-01-26 15:28 出处:网络
I want开发者_如何学C to perform the following operation: decimal = decimal? * float / 100 What\'s the most efficient way to do this?Do you want the result as a float

I want开发者_如何学C to perform the following operation:

decimal = decimal? * float / 100

What's the most efficient way to do this?


Do you want the result as a float

var result = ((float)d) * f / 100;

or as a decimal

var result = d * ((decimal)f) / 100;

I certainly question the mixing of decimal and float types though. Some context would help!

0

精彩评论

暂无评论...
验证码 换一张
取 消