Retro Rocket Kernel
BASIC-Powered Operating System
fpu.h File Reference
#include "kernel.h"

Functions

void enable_fpu ()
 Enable floating point operations. More...
 
void enable_sse ()
 Enable SSE. More...
 
uint8_t double_determine_decimal_places (double f)
 Determine the approximate number of decimal places in a double value. This uses a very simple loop which repeatedly multiplies the value by ten, until all that remains is a whole number greater than or equal to 1. More...
 
char * double_to_string (double x, char *p, int64_t len, uint8_t precision)
 Convert a doubleing point number to char* string, with a specified decimal precision. More...
 

Detailed Description

Author
Craig Edwards (craig.nosp@m.edwa.nosp@m.rds@b.nosp@m.rain.nosp@m.box.c.nosp@m.c)

Function Documentation

◆ double_determine_decimal_places()

uint8_t double_determine_decimal_places ( double  f)

Determine the approximate number of decimal places in a double value. This uses a very simple loop which repeatedly multiplies the value by ten, until all that remains is a whole number greater than or equal to 1.

Parameters
fdouble to count decimal places
Returns
uint8_t number of decimal places

◆ double_to_string()

char* double_to_string ( double  x,
char *  p,
int64_t  len,
uint8_t  precision 
)

Convert a doubleing point number to char* string, with a specified decimal precision.

This function retains accuraccy by converting to 64 bit integers and string representations as early as possible, then operating on fixed-point representations of the floating point number. When we deal with fixed point, we don't lose accuraccy due to rounding.

Parameters
xFloat to convert
pOutput buffer
lenSize of output buffer
precisionPrecision of decimal part. Set to 0 to display full stored precision of the value.
Returns
char* pointer to value in buffer

◆ enable_fpu()

void enable_fpu ( )

Enable floating point operations.

◆ enable_sse()

void enable_sse ( )

Enable SSE.

Warning
Do not use, this is not stable!