CSharp · Console
using System;
using System.Collections.Generic;
public class Program
{
public static void Main()
{
List<double> list = new List<double>()
{
2.7, -3.5, 0.6, 34.83, 7.458, 0, 9.20, -20.40, 12.2
};
int digits=0;
double nr = Double.NaN;
for(int i = 0; i < list.Count; ++i)
{
if((list[i] % 1) == 0) continue; // If the number does not have digits: 5.0, 3.0, 7, etc.
// https://stackoverflow.com/questions/2751593/how-to-determine-if-a-decimal-double-is-an-integer
string nrstring = list[i].ToString();
string aftercomma = nrstring.Split('.')[1];
if(aftercomma.Length > digits)
{
digits = aftercomma.Length;
nr = list[i];
}
}
Console.WriteLine(nr);
}
}