elks-enhanced
public
Read
Owner: themaster
Branch: master
Commits: 6893
Updated: 2026-04-19 00:15
Git CLI clone URL
git clone https://www.xt-emporium.com/git/elks-enhanced.git
Fullscreen desktop URL
Code
Commits
History
Branches
Bug Reports
Discussions
Compare
Settings
elks-enhanced
/
libc
/
misc
/
dtostr.c
File editor
#ifndef __HAS_NO_FLOATS__ /* * floating point output * * Added 'g' output format * Apr 2022 Greg Haerr */ #include <stdio.h> #include <stdlib.h> #include <ctype.h> void dtostr(double val, int style, int preci, char *buf) { int decpt, negative, diddecpt = 0; char * cvt; style = tolower(style); if (preci < 0) preci = 6; if (style == 'e') cvt = ecvt(val, preci, &decpt, &negative); /* preci = ndigits */ else cvt = fcvt(val, preci, &decpt, &negative); if(negative) *buf++ = '-'; if (decpt<=0) { *buf++ = '0'; *buf++ = '.'; diddecpt = 1; while(decpt<0) { *buf++ = '0'; decpt++; } } while(*cvt) { *buf++ = *cvt++; if (decpt == 1) { *buf++ = '.'; diddecpt = 1; } decpt--; } while(decpt > 0) { *buf++ = '0'; decpt--; } *buf = 0; if (style == 'g' && diddecpt) { for (;;) { int c = *--buf; if (c == '0' || c == '.') *buf = 0; if (c != '0') break; } } } #endif /* __HAS_NO_FLOATS__ */
Commit message
This repository is read-only for this account.
Repository snapshot
Current branch
master
Visibility
public
Your access
Read
Remote
Configured
File activity
View file history