
Computer Science Computer Science Forum 
 LinkBack  Thread Tools  Display Modes 
November 1st, 2018, 08:22 PM  #1 
Banned Camp Joined: Oct 2018 From: Mumbai Posts: 18 Thanks: 0  Reverse of a floating or decimal point number
Reference : https://www.programmingsimplified.co...reversenumber Is it possible to write a computer program which will reverse a decimal or floating point number? Example : 341.54 Output : 45.143 Do we have to just change the data type to float or double instead of int in the above C program reference or the programming logic has to be also modified? Thanks & Regards, Prashant S Akerkar Last edited by akerkarprashant; November 1st, 2018 at 08:27 PM. 
November 1st, 2018, 10:29 PM  #2 
Senior Member Joined: Feb 2016 From: Australia Posts: 1,826 Thanks: 646 Math Focus: Yet to find out. 
Yes you could easily store each digit of a number in a vector and then just flip it and put the digits back together.

November 1st, 2018, 11:41 PM  #3 
Banned Camp Joined: Oct 2018 From: Mumbai Posts: 18 Thanks: 0 
Thank you. Can you please send me the computer program in C , C++ , Java , C# & Python programming languages ? I will compile with the respective compilers and run the program in the respective SDK. Once again , thank you. Thanks & Regards, Prashant S Akerkar Last edited by akerkarprashant; November 1st, 2018 at 11:43 PM. Reason: Content. 
November 2nd, 2018, 03:44 AM  #4  
Math Team Joined: Dec 2013 From: Colombia Posts: 7,664 Thanks: 2643 Math Focus: Mainly analysis and algebra  Quote:
The art of programming is to pick the language to suit the application. There's no point in writing something so basic in so many languages unless you are doing it for practice. Perl: Code: > perl e 'print scalar(reverse shift), "\n";' 3.14 41.3 Last edited by v8archie; November 2nd, 2018 at 03:56 AM.  
November 2nd, 2018, 07:22 AM  #5 
Banned Camp Joined: Oct 2018 From: Mumbai Posts: 18 Thanks: 0 
Thanks. https://perlmaven.com/reverse As you mentioned in Perl code, the scalar function is called which could be the inbuilt function in the Perl math or string library. Can you give me the source code of the scalar function? This is required to know the algorithm or programming logic for giving us the reverse of a floating or decimal point number. As you see, https://www.programmingsimplified.co...reversenumber There is a source code for reverse of a Integer data type. Similarly, Can we have the source code of a reverse of a floating or decimal point number? Thanks, once again. Thanks & Regards, Prashant S Akerkar Last edited by akerkarprashant; November 2nd, 2018 at 07:33 AM. Reason: Content 
November 2nd, 2018, 08:24 AM  #6 
Global Moderator Joined: Dec 2006 Posts: 20,753 Thanks: 2136 
Reversing a floating point number isn't properly defined in the question. The example reverses a number given in decimal form, not floating point form.

November 2nd, 2018, 10:06 AM  #7  
Math Team Joined: Dec 2013 From: Colombia Posts: 7,664 Thanks: 2643 Math Focus: Mainly analysis and algebra  Quote:
The scalar function forces the reverse function to treat the input as a string rather than as an element of an array.  

Tags 
algorithm, decimal, floating, number, point, reverse 
Thread Tools  
Display Modes  

Similar Threads  
Thread  Thread Starter  Forum  Replies  Last Post 
exercise problem IEEE 754 floating point  abdel  Computer Science  4  June 14th, 2017 12:30 AM 
floating point numbers with modulus(mod)  abady1  Number Theory  5  September 21st, 2013 02:08 PM 
Floating Point Notation...  Primalscientist  Computer Science  9  June 2nd, 2011 06:29 AM 
Precision Arithmetic: A New FloatingPoint Arithmetic  Chengpu  Linear Algebra  0  May 23rd, 2010 04:55 PM 
Floating Point Numbers  Single Precision Format (help!)  RonnieStokie  Algebra  3  December 12th, 2007 09:36 PM 