How to represent the Real type in C#?

Asked

Viewed 734 times

2

I have an existing table in a bank of a client of mine and there has an attribute with the data type REAL. Like I do at C#? float or decimal? Which is the best way?

1 answer

3


It depends on the content. It depends on whether you want accuracy of values.

Most of the time I go decimal which gives accuracy, it is useful for monetary or other typical values that exact unity is important, this holds true for various types of measures. But the database would need to be with a compatible guy.

But it can go from double, eventually float. If in the database is as REAL, should be the most appropriate, the semantics of the real type is floating point like those types of C#.

What you may wonder is if the database is wrong and already causing problem to the system.

  • This information I do not have, what passes that is for interest, commissions and I found more suitable the use of decimal, but it may be that some other information that I do not know.

  • If this is what it’s for decimal,m need to be like this in the database too.

  • If it’s for interest it’s wrong, it’s causing damage to the company, be it for values, be it for image.

  • I don’t get it, big. How do I lose? So what kind do I represent in C# the REAL of Sql Server?

  • 1

    The problem is that the database is wrong, if it’s interest, forget it real, This is wrong, probably the whole system is wrong. See: https://answall.com/q/38138/101 and https://answall.com/questions/tagged/valor-monet%C3%a1rio? Sort=votes&pageSize=50. A lot of the existing systems are causing damage out there, including generating supervisory fines because the values go wrong.

  • Got it now, in reality their database is strange, but I’m just creating a mobile application and this step is part of the Rest that will enable the application. The field time and date of them is float, for example, but I have no way to change this, there are already some 8 years like this and I just want to make my App for them, sell, receive and negotiate other demands. Anyway, I’ll take your comment to them and let them make their own decisions. I will use the decimal, because C# does not have the Real, for monetary fields. Thanks.

  • Yes, everything is in trouble, learn to do it right, but this seems to be a lost cause. At least your part will be right for other databases.

Show 2 more comments

Browser other questions tagged

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