Go to the previous, next section.

 beginning-of-buffer with an Argument

When  beginning-of-buffer is called with an argument, an expression is evaluated which calculates what value to pass to  goto-char . This expression is rather complicated at first sight. It includes an inner  if expression and much arithmetic. It looks like this:

(if (> (buffer-size) 10000)
    ;; Avoid overflow for large buffer sizes!
    (* (prefix-numeric-value arg) (/ (buffer-size) 10))
  (/
   (+ 10
      (*
       (buffer-size) (prefix-numeric-value arg))) 10))

Like other complex-looking expressions, this one can be distangled by looking at it as parts of a template, in this case, the template for an if-then-else expression. When in skeletal form, the expression looks like this:

(if (buffer-is-large
    divide-buffer-size-by-10-and-multiply-by-arg
  else-use-alternate-calculation

The true-or-false-test of this inner  if expression checks the size of the buffer. The reason for this is that version 18 Emacs Lisp uses numbers that are no bigger than eight million or so (bigger numbers are not needed) and in the computation that follows, Emacs might try to use over-large numbers if the buffer were large. The term `overflow', mentioned in the comment, means numbers that are over large.

There are two cases: if the buffer is large and if it is not.

Go to the previous, next section.