[CCC DEV] convert.module and friends question
Matt Jadud
jadudm at gmail.com
Mon Jun 28 19:23:12 BST 2010
On Mon, Jun 28, 2010 at 1:23 PM, Adam Sampson <ats at offog.org> wrote:
> Matt Jadud <jadudm at gmail.com> writes:
> That's probably the right way to do it (you're definitely correct in
> thinking that occam code should use INT32 when it wants a 32-bit
OK.
> In terms of code for actually printing stuff, I'd recommend using the
> fairly comphrensive facilities that useful.module provides rather than
> inventing another API. You can say things like:
I have no desire to implement a new API. I'd rather leverage the
libraries and documentation.
> at http://occam-pi.org/occamdoc/useful.html). Note that the "r"
> formatter is implemented using the course library's copy of
> REAL32TOSTRING rather than convert's version, which is similarly stubbed
> out to CAUSEERROR () on 16-bit platforms.
That might be a smaller/easier piece of code to make updates to...
I'll take a look there next.
> A quick fix for now would be to add an FFI call that wraps up
> snprintf(buf, sizeof buf, "%f", value), and make REAL32TOSTRING call
> that. The formatting won't be quite the same as REAL32TOSTRING, but
> it'll be close enough.
My next email asked the question whether or not REAL32s pass through
the FFI nicely on this platform. They're more than one word in size;
according to David's document, a VAL REAL32 would be passed as a...
float? That said, on this platform, the REAL32 takes up two words,
which couldn't come through as a single value in args[]...
I've poked a bit at this approach, but am not yet certain how best to
ascertain how the REAL32 crosses the occam/C barrier.
> A lower-tech approach, if you have a reasonable idea of how big the
> numbers you're going to be dealing with are, is to write something that
> (for example) multiplies by 1000, converts the result to a 32-bit
> integer, then prints it putting a decimal point three digits from the
> end...
Yeah, we may do that this evening to get them rolling, and work on
something "better" in the meantime.
Cheers,
Matt
More information about the developers
mailing list