[CCC DEV] Question about INT32TOSTRING and friends

Adam Sampson ats at offog.org
Tue Jun 15 08:26:15 BST 2010


Matt Jadud <jadudm at gmail.com> writes:

> Basically, I was hoping not to have to re-write this kind of code. Is
> it LONGDIV that causes the problem? Or something else?

I added the conditional there back when I was stubbing out everything
that didn't trivially work on 16-bit platforms.

INT is 16 bits on 16-bit platforms, so INTTOSTRING works fine but only
handles 16-bit numbers. There's nothing inherently word-sizey about its
implementation other than the use of LONGDIV (which only takes INTs), so
it'd be fairly straightforward to produce an INT32TOSTRING from it that
could be dropped into int32ta.occ for 16-bit platforms.

It's not immediately obvious to me why that code uses LONGDIV at all,
since the value it passes is in the positive half of the signed range,
and the high word is always 0. There's a similar bit of code that uses
regular modulo in PROC format.int in modules/useful/libsrc/format.occ.

-- 
Adam Sampson <ats at offog.org>                         <http://offog.org/>




More information about the developers mailing list