Re: Whats the problem in this function?
- Posted by Robert B Pilkington <bpilkington at JUNO.COM> Aug 04, 1998
- 461 views
On Tue, 4 Aug 1998 15:42:47 +0900 Steve Lee <kodjak at INOUT.CO.KR> writes: (Well, this is what I see) >b3duIGJ5IGRpZ2l0ICVkIGludG8gJTQuNWYgXG4iLHtudW1iZXIsaSx2YWx1ZX0pDQogZW5kIGlm >LS0gU3RldmUuDQogCQ0KDQoNCg== > Well, the fact that it's all MIME code with no visible header and it's not in Euphoria would be one clue... ;) My DOS MIME en/decoder needs a header to do anything with the message.. :/ Can you set your mail reader to plain text (like David Cuny did :) so it can be readable to everybody, including those without any decoders. Well.. I managed to fake a header into the file using another MIME message I got, some of the comments were garbled but all the code seemed fine. I haven't found the problem, but maybe somebody else can now. -- I made the function that returns the rounded-up,down,off(is it right expression? my english -- is somhow poor :) value on the given digit. -- but when used in the main program, i got a problem on calculating Round-Down process. -- an example blelow. global constant ROUND_UP = 1, --(Garbage was here (ASCII chars above 128) ROUND_DOWN = 0, --(ditto) ROUND_OFF = 0.5 --(more) global function round_number(atom flag, object number, integer digit) -- flag : (MORE GARBAGE) -- number : (MORE!) -- digit : (MORE!) -- (more! Somewhere there's "There's no digit 0!" then more...) object answer if digit = 0 then answer = "There's no digit 0!" elsif digit < 0 then answer = floor(number/power(10,digit+1)+flag)*power(10,digit+1) elsif digit > 0 then answer = floor(number/power(10,digit)+flag)*power(10,digit) end if return answer end function atom number object value number = 1648.174 for i = 2 to -6 by -1 do value = round_number(ROUND_DOWN,number,i) if i = 0 then puts(1,value&'\n') else printf(1,"%4.5f rounded down by digit %d into %4.5f \n",{number,i,value}) end if end for -- now result below --1648.17400 rounded down by digit 2 into 1600.00000 --1648.17400 rounded down by digit 1 into 1640.00000 --There's no digit 0! --1648.17400 rounded down by digit -1 into 1648.00000 --1648.17400 rounded down by digit -2 into 1648.10000 --1648.17400 rounded down by digit -3 into 1648.17000 --1648.17400 rounded down by digit -4 into 1648.17300 -> problem starts to occur!! expecting -- 1648.17400!! --1648.17400 rounded down by digit -5 into 1648.17390 --1648.17400 rounded down by digit -6 into 1648.17399 -- I know many other excellent routines for this job but i still want to know WHAT IS THE -- PROBLEM IN MY ALGORITHM!! -- Steve. _____________________________________________________________________ You don't need to buy Internet access to use free Internet e-mail. Get completely free e-mail from Juno at http://www.juno.com Or call Juno at (800) 654-JUNO [654-5866]