Code Monkey home page Code Monkey logo

c99-snprintf's People

Contributors

ctarbide avatar tmolitor-stud-tu avatar weiss avatar zfields avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

c99-snprintf's Issues

MSVC 64-bit warning C4267

Visual Studio 2010 prints the C4267 conversion warnings on warning level /W3

snprintf.c(723): warning C4267: '=': Konvertierung von 'size_t' nach 'long', Datenverlust möglich
snprintf.c(768): warning C4267: '=': Konvertierung von 'size_t' nach 'long', Datenverlust möglich
snprintf.c(858): warning C4267: '=': Konvertierung von 'size_t' nach 'char', Datenverlust möglich
snprintf.c(862): warning C4267: '=': Konvertierung von 'size_t' nach 'short', Datenverlust möglich
snprintf.c(866): warning C4267: '=': Konvertierung von 'size_t' nach 'long', Datenverlust möglich
snprintf.c(870): warning C4267: '=': Konvertierung von 'size_t' nach 'long', Datenverlust möglich
snprintf.c(885): warning C4267: '=': Konvertierung von 'size_t' nach 'long', Datenverlust möglich
snprintf.c(889): warning C4267: '=': Konvertierung von 'size_t' nach 'long', Datenverlust möglich
snprintf.c(893): warning C4267: '=': Konvertierung von 'size_t' nach 'int', Datenverlust möglich

New release?

There has not been any new release since v1.1 from 2008. Is there any chance to have a new released version to get the changes from 2014 also in downstream repos, that still depend on v1.1? Thanks a lot?

Static analysis: Overflowed return value

Coverity Scan reports an Overflowed return value from function myround.

static UINTMAX_T
myround(LDOUBLE value)
{
    UINTMAX_T intpart = cast(value);

//1. Condition (value -= intpart) < 0.5, taking false branch.
//2. overflow: Add operation overflows on operands intpart and 1UL.
//CID 59973 (#1 of 1): Overflowed return value (INTEGER_OVERFLOW)
//3. overflow_sink: Overflowed or truncated value (or a value computed from an overflowed or truncated value) ((value -= intpart) < 0.5) ? intpart : (intpart + 1UL) used as return value.
    return ((value -= intpart) < 0.5) ? intpart : intpart + 1;
}

MSVC 64-bit warning C4244

Visual Studio 2010 prints the C4244 conversion warnings on warning level /W3

snprintf.c(1184): warning C4244: '=': Konvertierung von 'long double' in 'unsigned long', möglicher Datenverlust
snprintf.c(1436): warning C4244: '=': Konvertierung von 'long double' in 'unsigned long', möglicher Datenverlust

Requires floating point excess precision on x86 with gcc

It turns out that the tests fail on linux on Intel if you add the following code:

void 
set_fpu (unsigned int mode)
{
  asm ("fldcw %0" : : "m" (*&mode));
}

and then

set_fpu(x27f);

at the start of main. This (according to https://www.linuxtopia.org/online_books/an_introduction_to_gcc/gccintro_70.html ) sets excess precision to be disabled. This makes it compatible with other platforms that do not support excess precision.

Indeed, the results that I then get from x86 compare to those that I get from a microcontroller platform.

The failed tests seem to indicate that the system sprintf is doing something different. The worst cases appear to be with very small exponents. For example:

Results don't match, format string: %.16e
         sprintf(3): [1.6784992078596053e-265] (23)
        snprintf(3): [1.6784992078596017e-265] (23)
Results don't match, format string: %.16e
         sprintf(3): [1.6784992078596089e-265] (23)
        snprintf(3): [1.6784992078596053e-265] (23)

I am a bit puzzled by the fact that the x86 code is using long double and the microcontroller platform is not.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.