Did the BCPL programming language support floating point? If not, then how did programmers use it to add two floating point numbers?

  • Metacomco BCPL for the Sinclair QL (1984) did sortof support floating point in vectors (but not as a stand-alone type) – tofro Apr 26 '19 at 16:52

BCPL did include floating point, but only as an extension and some smaller systems chose not to implement it. The Arnor Z80 BCPL compiler I learned on did not support FP.

The Tenex BCPL manual (1974) describes its floating point operations and representations as being relatively standard: one could add two floats with the + operator, as expected.

The bcpltape distribution (1984) notes in its TRIPOS BCPL Standard manual that:

       1.10.1979                                                  67
                               BCPL Standard
       A13 Floating point
          There  are  two  possible  schemes  for  a  floating point
       package in BCPL:  on implementations where the cell  size  is
       big  enough  to hold the machine representation of a floating
       point number  the  Floating  Point  Language  Packet  may  be
       implemented and where this is not possible the Floating Point
       Procedure Packet may be  implemented.   In  either  case  the
       Floating Point I/O Procedures should be implemented.

BCPL's Floating Point Language Packet - for machines large enough to hold FP values in a memory cell - prefixed the corresponding integer operation with the character #, such as #+, #-, etc. So two numbers could be added using


The Floating Point Procedure Packet - for machines where FP values were held as a vector of cells - used special functions, including (again from the Tripos manual):

       Arithmetic Functions
          FPLUS(A,B,C)    C:=A#+B     resultis C
          FMINUS(A,B,C)   C:=A#-B     resultis C
          FNEG(A,B)       B:=#-A      resultis B
          FMULT(A,B,C)    C:=A#*B     resultis C
          FDIV(A,B,C)     C:=A#/B     resultis C
          FABS(A,B)       B:=#ABS A   resultis B

Floating point support was clearly implementation-specific, and would need to be reviewed on attempting to port software from one site to another.

| improve this answer | |
  • maybe I should have said “BCPL could include floating point …”, as Martin Richards was seemingly dead-set against it until very recently. Other implementations were free to add it as they saw fit. – scruss Apr 26 '19 at 15:42

No, BCPL did not support floating point, unless the system's native word was interpreted as a floating point value. It also didn't support any other types.

From the BCPL manual, section 1.0, point 2:

All data items have Rvalues which are bit patterns of the same length and the type of an Rvalue depends only on the context of its use and not on the declaration of the data item. This simplifies the compiler and improves the object code efficiency but as a result there is no type checking.

An "Rvalue" is, basically, a value that can be used on the right-hand side of an assignment. It's the opposite of an "Lvalue", which (again basically) is something that can be assigned to.

Considering its intended use:

BCPL is a simple recursive programming language designed for compiler writing and system programming [...]

it seems doubtful that floating-point processing would be an important enough feature to include, especially in a world where many systems might not be floating-point capable at all. The manual also doesn't mention "float", and "decimal" only appears once in the meaning of "base 10".

| improve this answer | |
  • When I used floats in BCPL, they were defined as 2-word vectors. There were routines to assign values, do arithmetic and print floats. The arithmetic was worked out in reverse polish before it was coded. It was pretty awful to use – cup Apr 27 '19 at 18:37

No, but Martin Richards has recently added floating point operators, with a funny kind of type inference to distinguish between integer and floating point arithmetic. From https://www.cl.cam.ac.uk/~mr10/bcplman.pdf, page 32:

BCPL was originally designed for the implemention of compilers and other system software such as text editors, pagination programs and operating systems. These applications typically did not require floating point and so the language did not include any floating point features. Indeed, many early machines on which BCPL ran had word lengths of 16 or 24 bits which were of insufficient length for useful floating point numbers. Even on 32-bit machines the precision of floating point numbers is limited to about 6 decimal digits which is insuffient for serious scientific calculations. For 50 years I resisted putting floating point into BCPL but have recently given in.

| improve this answer | |
  • interesting to see that Richards added it for the BCPL interface with the OpenGL graphics library on the Raspberry Pi – scruss Apr 26 '19 at 15:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.