[FFmpeg-devel] [PATCH] Implement the function cmdutils.c:parse_int_or_die

Stefano Sabatini stefano.sabatini-lala
Sun Feb 17 20:50:19 CET 2008

On date Sunday 2008-02-17 13:40:47 -0500, D. Hugh Redelmeier encoded:
> | From: Michael Niedermayer <michaelni at gmx.at>
> | Id prefer
> | double parse_number_or_die(const char* numstr, int type, double min, double max, const char* error);
> | 
> | d= parse_number_or_die("12234", OPT_INT, 1, 100, "blah blah");
> I really really distrust using floating point when integers are
> expected.  (To be honest, I distrust using floating point for anything
> where an exact result is expected.)
> Do we really want to allow "3.9" when the context calls for an integer?
> Theoretically, a C implementation could have some ints that are not
> representable as doubles.  I don't think that such an implementation
> exists, but it still makes me uncomforable.

Attached patch proposes a solution which implements MN suggestion, for
what regards the double to int conversion we could simply split the
function int three different ones, like:

int parse_int_or_die(...)
int64_t parse_int64_or_die(...)
float parse_float_or_die(...)

Stefano Sabatini
Linux user number 337176 (see http://counter.li.org)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: implement-parse-number-or-die-00.patch
Type: text/x-diff
Size: 4546 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20080217/65cdc2b9/attachment.patch>

More information about the ffmpeg-devel mailing list