.net - C# get digits from float variable -


I have a float variable and I would like to get only one part after comma, so if I have 3.14 I I want to get it in the form of an integer how can I do this?

The method of fraud is to:

  Private Int32 FractionalPart (double en) {string s = n.ToString ("########", System.Globalization.CultureInfo.InvariantCulture); Return Int32.Parse (s.Substring (s.IndexOf (".") + 1)); }  

edit2: okay okay okay. Here is the worst hypocrisy version I can come up with. This floating point will return the first 9 digits (or less, if not many) of the decimal part of the number. It is guaranteed to not overflow an Int32, we use irreversible culture, so we know that we can use it as a decimal separator.


Comments

Popular posts from this blog

c++ - Linux and clipboard -

What is expire header and how to achive them in ASP.NET and PHP? -

sql server - How can I determine which of my SQL 2005 statistics are unused? -