TGC Codebase Backup



Floating point number to text with x decimal points by EdzUp

30th Nov 2008 10:09
Summary

A function that will take a floating point value and return a string equivalent to x decimal points.



Description

A function that will take a floating point value and return a string equivalent to x decimal points. Basically if you use it with say 85963.99934343 and two decimal points it will return 85963.99.

This can be handy when you want to display things like distances to an object that is a float.



Code
                                    ` This code was downloaded from The Game Creators
                                    ` It is reproduced here with full permission
                                    ` http://www.thegamecreators.com
                                    
                                    function ReturnPointData( Value#, points )
   rem this will return the part of the value requested so 894.87123 with points of 2 would return 894.87 :D
   if points>8
      points=8
   endif
   
   Temp$ = left$( str$( Value# ), find sub string$( str$( Value# ), "." ) +points )

endfunction Temp$