Absolute integer Kategorie: Programmierung Basic (von PepeV - 14.01.2011 10:29) | ||
| ||
Hi all, The library of the Pro-Bot128 contains the following function to calculate the absolute value of an integer. Sub ABS_INT(Val As Integer) As Integer Dim X_Save As Integer If Val<-0 Then X_Save=Val Val=X_Save-Val Val=Val-X_Save Return Val Else Return Val End If End Sub Can someone explain me why it is so complex? Why not simply: Sub ABS_INT(Val As Integer) As Integer If Val<0 Then Val=-Val Return Val End Sub Or could one use fabs() on integers? If so, what are the consequences for the program speed? Regards, Pepe | ||
Antwort schreiben Antworten: |
Zur Übersicht - INFO - Neueste 50 Beiträge - Neuer Beitrag - Suchen - Zum C-Control-I-Forum - Zum C-Control-II-Forum