Posted: Sun Mar 19, 2006 5:22 pm
when i round 1 number from point gives 3.4999999 = 3
when round 2 number from point gives 3.4999999 = 3.5
when round 2 number from point gives 3.4999999 = 3.5
http://www.purebasic.com
https://www.purebasic.fr/english/
Code: Select all
Procedure.f froundint(num.f)
!fld dword[p.v_num]
!frndint
ProcedureReturn
EndProcedure
Debug froundint(1.4)
Code: Select all
j.d=0
For i = 1 To 7
j=i
n=j/2.0
Debug n
Next i
Code: Select all
; Str is the real Round function...
Debug StrD(#PI,3)
Debug StrD(#PI*10000,0)
Debug Round(#PI*10000,0)
; other effects...
Debug 1e50; also nice: the 1 in the middle and the .0 at the end
Debug StrD(1e160*1e160); two more jokes, the "unlimited" range of the help text and some zeros at the end
Code: Select all
; Original
a.d=5.6
Debug a
Debug StrD(a)
Code: Select all
; Alternative
#maxstellen=10
Procedure.s strx(d.d,stellen.w=0)
Protected tmp.s
Protected k.w,n.w
If stellen=0
tmp=StrD(d,#maxstellen)
k=Len(tmp)
n=#maxstellen+2; #nks+1 läßt Komma stehen...
While n>1
k-1
n-1
If PeekB(@tmp+k-1)>48; 1,2,...,9 und '.'
n=0
EndIf
Wend
ProcedureReturn Left(tmp,k)
Else
ProcedureReturn StrD(d,stellen)
EndIf
EndProcedure
a.d=5.5
Debug strx(a)
Debug strx(a,5)
In this we are absolutely in accordance.Michael Vogel wrote:of course, the round command should be changed.
inacordance? sounds so negativePsychophanta wrote: In this we are absolutely inacordance.
Does everyone feel comfortable with the results of Pure Basic ( 0 / 1 / 2 / 2 / 2 / 3 / 4) ?j.d=0
For i = 1 To 7
j=i
n=j/2.0
Debug n
Next i
Code: Select all
DEFDBL "j"
DEFINT "i,n"
j = 0
FOR i = 1 TO 7
j = i
n = j / 2.0
PRINT n
NEXT i