Does anyone know how to convert a floating point number into an integer value ? thanks.
float to integer
Collapse
X
-
Thanks but i managed to make a DLL in C++ that does the job
Code:function GetInt(FloatNumber) return DLL.CallFunction("AutoPlay\\Dlls\\Integers.dll", "ReturnInt", FloatNumber, DLL_RETURN_TYPE_INTEGER, DLL_CALL_STDCALL); end
Attached Files
Comment
-
-
Thinking about it... its far easyer to convert the number to a string and then just return everything left of the decimal point;
Code:function ConvertToInt(Anumb) if String.Find(Anumb.."", ".", 1, false) > 1 then Anumb = String.ToNumber(String.Left(Anumb.."" , String.Find(Anumb.."", ".", 1, false)-1)); end return Anumb end
Comment
-
-
Originally posted by clueless View PostThinking about it... its far easyer to convert the number to a string and then just return everything left of the decimal point;
Comment
-
-
Originally posted by Desolator View PostMath.Round? :P
Anyway, AMS sends numbers as `long int', thus no floating-point numbers unless you make a plug-in.
..and what do I know anyway - I never listened to my Maths Teachers
Comment
-
-
I was adding a crop function to an animation editor im making. The user sellects the frame to be cropped which is passed to a cropping page which displays the picture with a rectangle in the center representing the area to be cropped. because the frame size is not fixed i needed to calculate the size of the cropping rectangle relative to the size of the frame. If you try to set the co-ordinates of a rectangle with anything other than whole numbers it just wont work.
Code:FileInfo = Image.GetFileInfo(LoadPic); TheWidth = FileInfo.Width; TheHeight = FileInfo.Height; Ax = GetInt(TheWidth / 4); Ay = GetInt(TheHeight / 4); Bx = Ax * 3 By = Ay * 3; RectangleWidth = Bx - Ax; RectangleHeight = By - Ay; Image.SetSize("Image1", TheWidth, TheHeight); Image.Load("Image1", DrawRectangle(LoadPic, Colors.White, 1, Ax, Ay,RectangleWidth, RectangleHeight));
Comment
-
Comment