Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.os.linux.advocacy > #456421
| From | owl <owl@rooftop.invalid> |
|---|---|
| Newsgroups | comp.os.linux.advocacy |
| Subject | Re: linking sc to libgmp |
| Date | 2018-06-25 21:20 +0000 |
| Organization | O.W.L. |
| Message-ID | <xy4a889b3.abhip3@rooftop.invalid> (permalink) |
| References | <xl9080ab3.aghou3@rooftop.invalid> <3f5ac451-83d5-49cb-b211-c42bbc5f75d9@googlegroups.com> |
Steve Carroll <fretwizzer@gmail.com> wrote:
> On Monday, June 25, 2018 at 8:55:24 AM UTC-6, owl wrote:
>> Finally figured out how to create a built-in arbitrary precision
>> addition function for sc. This first attempt simply adds two cells.
>>
>> https://pewtube.com/user/owl/pdscsXX?autoplay=off
>>
>> Because sc's internal floating-point representation is a double, and
>> therefore limited to that precision, the numbers for arbitrary precision
>> math must entered as strings, with the function returning a string.
>>
>> The function itself was easy enough, but figuring out how to get
>> sc to save it took a lot of digging through the code.
>
> Why?
>
Because it was buried in a non-obvious (to me) place. The code that
causes the function to appear in the info line at the top when the
cursor is over a cell containing a function, as in the image below where
it shows:
A2 (78 2 0) <{@sadd(A0,A1)}
https://imgur.com/a/Z9f2Fsz
is also responsible for having the function written to a saved file.
This is the code (in interp.c):
void
decompile(register struct enode *e, int priority)
{
register char *s;
if (e) {
int mypriority;
switch (e->op) {
...
case SADD: two_arg("@sadd(", e); break;
...
}
Without that case statement, the function, even though working correctly,
displays as:
A2 (78 2 0) <{A0M(A1)}
and is written to a saved file as:
leftstring A2 = AOM(A1)
When written that way, the function of course does not work when the file
is reloaded. After adding that case statement, the function gets properly
displayed as
A2 (78 2 0) <{@sadd(A0,A1)}
and written to the file as:
leftstring A2 = @sadd(A0,A1)
And now it works. :)
Back to comp.os.linux.advocacy | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
linking sc to libgmp owl <owl@rooftop.invalid> - 2018-06-25 14:55 +0000
Re: linking sc to libgmp Steve Carroll <fretwizzer@gmail.com> - 2018-06-25 13:10 -0700
Re: linking sc to libgmp owl <owl@rooftop.invalid> - 2018-06-25 21:20 +0000
Re: linking sc to libgmp Steve Carroll <fretwizzer@gmail.com> - 2018-06-25 14:33 -0700
Re: linking sc to libgmp owl <owl@rooftop.invalid> - 2018-06-25 21:48 +0000
Re: linking sc to libgmp Steve Carroll <fretwizzer@gmail.com> - 2018-06-25 14:56 -0700
Re: linking sc to libgmp owl <owl@rooftop.invalid> - 2018-06-25 22:17 +0000
Re: linking sc to libgmp Steve Carroll <fretwizzer@gmail.com> - 2018-06-25 15:23 -0700
Re: linking sc to libgmp owl <owl@rooftop.invalid> - 2018-06-25 22:48 +0000
Re: linking sc to libgmp Steve Carroll <fretwizzer@gmail.com> - 2018-06-26 08:11 -0700
csiph-web