Path: utzoo!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!usc!elroy.jpl.nasa.gov!decwrl!ucbvax!mis.mcw.edu!tenaglia From: tenaglia@mis.mcw.edu (Chris Tenaglia - 257-8765) Newsgroups: comp.lang.icon Subject: Correction to packed decimal converter Message-ID: <9001232228.AA03553@uwm.edu> Date: 23 Jan 90 18:56:10 GMT Sender: daemon@ucbvax.BERKELEY.EDU Distribution: inet Organization: The Internet Lines: 31 Several weeks ago I posted procedures for converting integers to and from packed format. After perfecting an application using them, a flaw became apparent in the procedure unpack(). Below is the corrected version. ################################################################## # # # THIS PROCEDURE UNPACKS A VALUE INTO AN INTEGER. # # # ################################################################## procedure unpack(val,width) # REQUIRES LINK RADCON ! local tmp,number,tens,ones,sign tmp := "" sign := 1 every number := ord(!val) do tmp ||:= right(map(radcon(number,10,16),&lcase,&ucase),2,"0") #this line changed if tmp[-1] == ("B" | "D") then sign := -1 tmp[-1] := "" tmp *:= sign /width := *tmp return right(tmp,width) end Yours truly, Chris Tenaglia (System Manager) Medical College of Wisconsin 8701 W. Watertown Plank Rd. Milwaukee, WI 53226 (414)257-8765 tenaglia@mis.mcw.edu