double2singlePrecision: Converts double to single precision.

.double2singlePrecisionR Documentation

Converts double to single precision.

Description

This function simulates the conversion of floating point numbers from double precision (64bit, R: double(), C: double) to single precision (32bit, R: none, C: float). It follows IEEE 754 standard.

Usage

.double2singlePrecision(x)

Arguments

x

double, numeric value which should reduce from double precision to single precision.

Details

The same could be done in C by using casts:

double precision32(double value) {
  float x=value;
  return (double)x;
}

Value

double (in single precision).

References

IEEE 754 standard: https://ieeexplore.ieee.org/xpl/articleDetails.jsp?arnumber=30711&filter=AND(p_Publication_Number:2355)

See Also

.changePrecision, .hpc

Examples

## load library
library("readBrukerFlexData")

## show more details
oldDigits <- options()$digits
options(digits=22)

## a test number
num <- 1/3

num
readBrukerFlexData:::.double2singlePrecision(num)

## reset digits option
options(digits=oldDigits)


readBrukerFlexData documentation built on Oct. 3, 2024, 1:06 a.m.