### 14` `Unsafe Operations Utilities

All functions and forms provided by racket check their arguments to ensure that the arguments conform to contracts and other constraints. For example, vector-ref checks its arguments to ensure that the first argument is a vector, that the second argument is an exact integer, and that the second argument is between 0 and one less than the vector’s length, inclusive.

Functions provided by racket/unsafe/ops are unsafe. They have certain constraints, but the constraints are not checked, which allows the system to generate and execute faster code. If arguments violate an unsafe function’s constraints, the function’s behavior and result is unpredictable, and the entire system can crash or become corrupted.

For efficiency, the Science Collection often uses unsafe operations internally —

The functions and macros described in the chapter can be made available using the form:

(require (planet williams/science/unsafe-ops-utils)) |

These routines are used to assure that a real variable (or vector) is represented as a floating-point number —

(real->float x) → inexact-real? |

x : real? |

(real-vector->float-vector v) → (vector-of inexact-real?) |

v : (vector-of real?) |

(real-vector->flvector v) → flvector? |

v : (vector-of real?) |