lucenenet-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "George Aroush" <geo...@aroush.net>
Subject Converting float values to string
Date Fri, 16 Jun 2006 20:27:04 GMT
Hi folks,

Some NUnit tests are failing because Lucene.Net.Util.ToStringUtils.Boost()
is not return the correct formatted float value as it would be in the Java
version.

For example, given he float value of 2, in Java you will get back the string
"2.0" -- but in C# it is giving back "2".  Here is the function in question:

	public static System.String Boost(float boost)
	{
		if (boost != 1.0f)
		{
			return "^" + boost.ToString();
		}
		else
			return "";
	}

If I change "boost.ToString()" to "boost.ToString("0.0")" it will work on
float values such as 1, 12.1, 9999.5, etc., where I get back "1.0", "12.1",
"9999.5", etc. -- however, this won't work for float values of 1.005, or
1.01.  In those cases, I get back "1.0".

Do you know how I can make this code work in .NET so that I get back "1.005"
and "1.01" -- as the Java version is doing it?

Regards,

-- George


Mime
View raw message