Re: adding numbers
- Posted by "Carl W." <euphoria at cyreksoft.yorks.com> Jun 06, 2002
- 434 views
"Derek Parnell" wrote: > That all depends on what the specification is. Some examples might help > here... > > So far we know that > {1,6} ==> {16} > must be true > > but we are assuming > {23,17} ==> {247} > > or this > {23, 17} = {2317} > > That is why clear specifications are so important for programming. Here's a quick kluge that deals with some of the apparent problems, but introduces a whole heap of others ;) ...: -- Warning! No error or bounds checking in this code! sequence in, outseq integer out in = {1, 23, 456} outseq = "" out = 0 -- want this to be 123456 for i = 1 to length(in) do outseq &= sprintf("%d", in[i])-'0' end for for i = 1 to length(outseq) do out = out * 10 + outseq[i] end for ? out Carl