# Single Percision Float on Chez-Scheme impl

**URL:** https://racket.discourse.group/t/single-percision-float-on-chez-scheme-impl/3687
**Category:** Questions & Answers
**Tags:** question
**Created:** [April 13, 2025, 8:19am UTC](https://racket.discourse.group/t/single-percision-float-on-chez-scheme-impl/3687 "2025-04-13T08:19:10Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![xiaoyu2006](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/xiaoyu2006/32/1682_2.png) [@xiaoyu2006](https://racket.discourse.group/u/xiaoyu2006)
#### Post date: [April 13, 2025, 8:19am UTC](https://racket.discourse.group/t/single-percision-float-on-chez-scheme-impl/3687/1 "2025-04-13T08:19:10Z")

</div>

A part of my Racket program _requires_ calculating single-precision float number that follows IEEE 754. However my Racket tells me `(single-flonum-available?) ; => #f`. How can I bypass this? I imagine I can have such api `(make-f32)` `(f32+ a b)`, etc.

---

<div class="post-metadata">

### Author: ![shawnw](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/shawnw/32/1031_2.png) [@shawnw](https://racket.discourse.group/u/shawnw)
#### Post date: [April 13, 2025, 9:58am UTC](https://racket.discourse.group/t/single-percision-float-on-chez-scheme-impl/3687/2 "2025-04-13T09:58:14Z")

</div>

The best you can do is to use [flonum](https://docs.racket-lang.org/reference/flonums.html#(part._flonums)) functions and wrap arguments and operator functions in an equation in [`flsingle`](https://docs.racket-lang.org/reference/flonums.html#%28def._%28%28lib._racket%2Fflonum..rkt%29._flsingle%29%29) calls. It's a pain.

```scheme
> (require racket/flonum)
> (flsingle (fl+ (flsingle 1.0) (flsingle 2.5)))
3.5

```

You can box them into single-element [`f32vector`](https://docs.racket-lang.org/foreign/homogeneous-vectors.html#%28def._%28%28lib._ffi%2Fvector..rkt%29._make-f32vector%29%29)s to make sure they're stored as singles.

```scheme
> (require ffi/vector)
> (define val (make-f32-vector 1))
> (f32vector-set! val 0 (flsingle (fl+ (flsingle 1.0) (flsingle 2.5))))
> (f32vector-ref val 0)
3.5

```

* * *

The lack of single-precision flonums and to a lesser extent extflonums in Racket CS is frustrating sometimes when trying to do numerical work.
