What is the best type to store area, volume, perimeter?

Asked

Viewed 74 times

7

Decimal, Numeric or Float. What is the best option for storing area or volume? I would use Decimal, but I would like to see the opinion of others as well. I guess not, but the right guy or the next guy makes all the difference 'cause I caught him with a bank full of guys REAL and I don’t want to waste time on the wrong guys. I used because in it I will map the bank’s types by the C#.

2 answers

9


Generally speaking the decimal is the most correct. Even if you don’t need the exactness in it interact with other units that need the bad contaminates the good and everything gets wrong.

Overall I see zero advantages in using a binary floating point type. Yes, it has more performance and should occupy less memory, but the risk is very great, especially in the hands of programmers who are not very sharp in software development and do everything very carefully, with a deep understanding of all the consequences. And everything is absurdly well documented, which never happens.

see more in What is the correct way to use the float, double and decimal types?.

0

It’s not widespread, but there are space types in C#. Of course it is possible to work with any type of floating point data, but in addition to storing you will certainly want to do calculations with these points. I already needed it for an academic job and it was a hand in the wheel.

https://docs.microsoft.com/pt-br/ef/core/modeling/spatial

Browser other questions tagged

You are not signed in. Login or sign up in order to post.