From: Damir Shayhutdinov <damir@tecon.ru> To: Andrey Rybak <ra@iop.kiev.ua> Cc: "Список рассылки по использованию дистрибутивов ALT Linux" <community@altlinux.ru> Subject: Re: [Comm] value overflow on C Date: Wed, 22 Feb 2006 15:56:40 +0300 Message-ID: <20060222125640.GH19814@damir.rnd.local> (raw) In-Reply-To: <43FC5E46.9000909@iop.kiev.ua> On Wed, Feb 22, 2006 at 02:51:18PM +0200, Andrey Rybak wrote: > > > ИМХО глобально решить проблему можно только если использовать другие языки. > > В случае целочисленных выражений проблему можно сгладить, просто взяв int > > тип пошире (например, long long). > > > > > В том то и дело, что взять тип пошире - не кошерно в моем случае. > Расчеты величин проходят в их (величин) зонах сингулярности, где область > значений резко увеличивается даже при малых изменениях аргумента. В > тоже время увеличив ширину типа, я увеличу и так большое время счета. Использование 64битных вычислений позволяет этого избежать. > Поэтому мне надо просто детектировать, что я подошел к предельным > величинам. Просто условными оператороми (if например) эта задача > решается неудовлетворительно. Почему? Даже с флажком от условного перехода (if) вы никуда не денетесь :( > А вопрос у меня возник, потому что помнится мне, что в ассемблере есть > флажок переполнения байта величины (при инкременте например), поэтому > думается мне, что при близости Си к низкоуровнему программированию, > такая фича (определение превышения допустимой величины) должна быть. > Именно поэтому я привел пример с ERANGE. > > Есть еще идеи? Написать на асме функцию сложения, использующую этот флаг и использовать ее, определив как inline для ускорения например. Правда это непортабельно. -- WBR, Damir Shayhutdinov
next prev parent reply other threads:[~2006-02-22 12:56 UTC|newest] Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top 2006-02-22 11:25 Andrey Rybak 2006-02-22 11:51 ` Damir Shayhutdinov 2006-02-22 12:51 ` Andrey Rybak 2006-02-22 12:56 ` Damir Shayhutdinov [this message] 2006-02-22 13:41 ` Andrey Rybak 2006-02-22 14:23 ` Serge Skorokhodov 2006-02-22 14:36 ` Andrey Rybak 2006-02-22 15:13 ` Yura Kalinichenko 2006-02-23 9:39 ` Serge Skorokhodov 2006-02-23 9:51 ` Kaydannik Axel 2006-02-22 19:54 ` Kosserior 2006-02-22 17:28 ` spider 2006-02-22 18:19 ` Хихин Руслан 2006-02-25 12:07 ` Andrey Rybak
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20060222125640.GH19814@damir.rnd.local \ --to=damir@tecon.ru \ --cc=community@altlinux.ru \ --cc=community@lists.altlinux.org \ --cc=ra@iop.kiev.ua \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: link
ALT Linux Community general discussions This inbox may be cloned and mirrored by anyone: git clone --mirror http://lore.altlinux.org/community/0 community/git/0.git # If you have public-inbox 1.1+ installed, you may # initialize and index your mirror using the following commands: public-inbox-init -V2 community community/ http://lore.altlinux.org/community \ mandrake-russian@linuxteam.iplabs.ru community@lists.altlinux.org community@lists.altlinux.ru community@lists.altlinux.com public-inbox-index community Example config snippet for mirrors. Newsgroup available over NNTP: nntp://lore.altlinux.org/org.altlinux.lists.community AGPL code for this site: git clone https://public-inbox.org/public-inbox.git