15,963,724 members
1.00/5 (1 vote)
See more:
Hai Friends ,
I am having a number say for eg : 12345.67 and what i need is to Reverse the number to 76.54321 ........... Is There any idea since I have idea only on reversing a int number . I am unable to find the solution for Double ......................
Posted
[no name] 24-Jun-13 7:33am
Simple, reverse the string 12345.67 then convert the result to double. If you can do it for an int, you should be able to do it for a double.
Rajesh Anuhya 24-Jun-13 7:40am
You can post it as a answer
--RA

## Solution 1

Hi,

Try this:
C#
```double d = 12345.67;
string reversedStr = new string(d.ToString().Reverse().ToArray());
double reversedDouble;
if (double.TryParse(reversedStr, out reversedDouble))
{
// now, reversedDouble is the reversed double
}
else
{
// unable to reverse the double
}```

Hope this helps.

MurugappanCTS 24-Jun-13 7:40am
thanks
Thomas Daniels 24-Jun-13 7:41am
You're welcome!

## Solution 2

Convert to string, reverse and convert it back to double. To write reverse function follow this link. http://stackoverflow.com/questions/228038/best-way-to-reverse-a-string[^]

MurugappanCTS 24-Jun-13 7:40am
thanks for ur help
ArunRajendra 25-Jun-13 4:40am
Welcome :)

## Solution 3

Hello,

Try this:

C#
```void Main()
{
double d = 12345.67;
Console.WriteLine("Reversed: {0}", ReverseNumber(d));
}

double ReverseNumber(double number)
{
return double.Parse(ReverseString(number.ToString()));
}

string ReverseString( string s )
{
char[] charArray = s.ToCharArray();
Array.Reverse( charArray );
return new string( charArray );
}```

Cheers,
JAFC