Re: Phix : win32lib7 project
- Posted by petelomax Dec 15, 2016
- 1610 views
ChrisB said...
how would you resolve w32Remainde({10,73,28}, {11, 3, 2 ,6, 14})
I am officially confused now. Test code:
function w32remainder(object a,object b) if sequence(a) then for i=1 to length(a) do -- a[i]=remainder(a[i],b) a[i]=w32remainder(a[i],b) end for return a elsif sequence(b) then -- for i=1 to length(a) do for i=1 to length(b) do -- b[i]=remainder(a,b[i]) b[i]=w32remainder(a,b[i]) end for return b end if if compare(a,0.0)=compare(b,0.0) then return remainder(a,b) else return b+remainder(a,b) end if end function ?w32remainder({10,73,28}, {11, 3, 2 ,6, 14})
Phix:
{{10,1,0,4,10},{7,1,1,1,3},{6,1,0,4,0}}eui (4.0.0):
{ {10,1,0,4,10}, {7,1,1,1,3}, {6,1,0,4,0} }exwc (2.4):
{ {10,1,0,4,10}, {7,1,1,1,3}, {6,1,0,4,0} }Further, these results match those from eui/exwc when (instead of recursive calls to w32remainder) using the original remainder (which causes phix grief).
Not that any of the results make any logical sense or seem of any practical value to me, of course, but at least they seem pretty consistent.
ChrisB said...
Oh, the error is coming from a call from w32Round() - I could potentially simplify that too.
I did notice, incidentally and not very importantly, this:
global function w32round(object a,object b,integer flag) atom diff integer sgn if sequence(a) then for i=1 to length(a) do a[i]=remainder(a[i],b) end for return a elsif sequence(b) then -- for i=1 to length(a) do for i=1 to length(b) do b[i]=remainder(a,b[i]) end for return b end if if b<=0.0 or a=0.0 then return a end if if sequence(a) then for i=1 to length(a) do a[i]=w32round(a[i],b,flag) end for return a end if
The last six lines are simply never going to be executed, which may speak for the quality of the rest of the code...
Plus those two calls to remainder() look extremely suspicious!
I think you are probably quite right about changing the parameters to be atom only.
Pete