From: Kevin Ryde <user42@zip.com.au>
Subject: ash docstring
Date: Sun, 19 Oct 2003 10:28:18 +1000 [thread overview]
Message-ID: <87vfqm2hr1.fsf@zip.com.au> (raw)
[-- Attachment #1: Type: text/plain, Size: 81 bytes --]
* numbers.c (scm_ash): Revise docstring as per recent update to manual.
[-- Attachment #2: numbers.c.ash-doc.diff --]
[-- Type: text/plain, Size: 1708 bytes --]
--- numbers.c.~1.204.~ 1970-01-01 10:00:01.000000000 +1000
+++ numbers.c 2003-10-19 10:27:26.000000000 +1000
@@ -1367,20 +1367,24 @@
SCM_DEFINE (scm_ash, "ash", 2, 0, 0,
(SCM n, SCM cnt),
- "The function ash performs an arithmetic shift left by @var{cnt}\n"
- "bits (or shift right, if @var{cnt} is negative). 'Arithmetic'\n"
- "means, that the function does not guarantee to keep the bit\n"
- "structure of @var{n}, but rather guarantees that the result\n"
- "will always be rounded towards minus infinity. Therefore, the\n"
- "results of ash and a corresponding bitwise shift will differ if\n"
- "@var{n} is negative.\n"
+ "Return @var{n} shifted left by @var{cnt} bits, or shifted right\n"
+ "if @var{cnt} is negative. This is an ``arithmetic'' shift.\n"
"\n"
- "Formally, the function returns an integer equivalent to\n"
- "@code{(inexact->exact (floor (* @var{n} (expt 2 @var{cnt}))))}.\n"
+ "This is effectively a multiplication by 2^@var{cnt}}, and when\n"
+ "@var{cnt} is negative it's a division, rounded towards negative\n"
+ "infinity. (Note that this is not the same rounding as\n"
+ "@code{quotient} does.)\n"
+ "\n"
+ "With @var{n} viewed as an infinite precision twos complement,\n"
+ "@code{ash} means a left shift introducing zero bits, or a right\n"
+ "shift dropping bits.\n"
"\n"
"@lisp\n"
"(number->string (ash #b1 3) 2) @result{} \"1000\"\n"
"(number->string (ash #b1010 -1) 2) @result{} \"101\"\n"
+ "\n"
+ ";; -23 is bits ...11101001, -6 is bits ...111010\n"
+ "(ash -23 -2) @result{} -6\n"
"@end lisp")
#define FUNC_NAME s_scm_ash
{
[-- Attachment #3: Type: text/plain, Size: 142 bytes --]
_______________________________________________
Guile-devel mailing list
Guile-devel@gnu.org
http://mail.gnu.org/mailman/listinfo/guile-devel
reply other threads:[~2003-10-19 0:28 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/guile/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87vfqm2hr1.fsf@zip.com.au \
--to=user42@zip.com.au \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).