Hi,
I have a very strange arithmetic problem in C:
double t = 0.1;
int steps = 10;
double time_step = t / (double)steps;
I would expect the output of time_step to be 0.01000 (my output is of
the form %5.5f), but instead it a very large (and incorrect) negative
number.
Any ideas?
Thanks,
Schiz
Jun 3 '06
26 2573
On Sun, 04 Jun 2006 00:05:04 -0400, CBFalconer <cb********@yah oo.com>
wrote: Schizoid Man wrote: ... snip ... scanf_s is a method that replaces scanf in the new Visual C++, scanf has been deprecated. Similarly, for the tchar.h file too.
Don't let yourself be brain washed by Micro$loth. scanf has NOT been deprecated. scanf_s is NOT a method, it is a non-standard function. There is a draft technical report n1146.pdf describing these things.
Using such non-standard things, and such other non-standards as stdafx.h, only locks your code into the Micro$oft way and is counter-productive.
Counter-productive to what? Surely not to making money, as you so
openly imply by using terms that begin with "Micro$". Microsoft has
allowed a lot of people to make money. And at the same time they've
made money themselves and have benefited the world immensely. I seem
to recall reading what one respectfull person said about Excel in this
thread.
It can be beneficial, sometimes, to reflect upon the past and
reconsider it in the present. Such a relection may lead to newly
discovered insights, however that may be hard to swallow juxtaposed
against past beliefs.
On 2006-06-05, jaysome <ja*****@spamco p.net> wrote: On Sun, 04 Jun 2006 00:05:04 -0400, CBFalconer <cb********@yah oo.com> wrote:
Schizoid Man wrote:... snip ... scanf_s is a method that replaces scanf in the new Visual C++, scanf has been deprecated. Similarly, for the tchar.h file too.
Don't let yourself be brain washed by Micro$loth. scanf has NOT been deprecated. scanf_s is NOT a method, it is a non-standard function. There is a draft technical report n1146.pdf describing these things.
Using such non-standard things, and such other non-standards as stdafx.h, only locks your code into the Micro$oft way and is counter-productive.
Counter-productive to what? Surely not to making money, as you so openly imply by using terms that begin with "Micro$". Microsoft has allowed a lot of people to make money.
Yes, and here at clc it's all about who has the most money. No one here
cares who can actually program in C.
And at the same time they've made money themselves and have benefited the world immensely. I seem to recall reading what one respectfull person said about Excel in this thread.
Uhh... how does introducing mass security exploits to the vast majority
of home users while at the same time exploiting its market share to keep
every single standard that has come along from acceptance. I'm referring
mainly to web standards here, but there are many, many other examples.
It can be beneficial, sometimes, to reflect upon the past and reconsider it in the present. Such a relection may lead to newly discovered insights, however that may be hard to swallow juxtaposed against past beliefs.
No, thinking about M$'s history just makes me angry.
--
Andrew Poelstra < http://www.wpsoftware.net/blog >
To email me, use "apoelstra" at the above address.
If we would just let the poachers into the zoo, we'd
have less squashed people and more fancy pianos!
jaysome wrote: CBFalconer <cb********@yah oo.com> wrote: Schizoid Man wrote: ... snip ... scanf_s is a method that replaces scanf in the new Visual C++, scanf has been deprecated. Similarly, for the tchar.h file too.
Don't let yourself be brain washed by Micro$loth. scanf has NOT been deprecated. scanf_s is NOT a method, it is a non-standard function. There is a draft technical report n1146.pdf describing these things.
Using such non-standard things, and such other non-standards as stdafx.h, only locks your code into the Micro$oft way and is counter-productive.
Counter-productive to what? Surely not to making money, as you so openly imply by using terms that begin with "Micro$". Microsoft has allowed a lot of people to make money. And at the same time they've made money themselves and have benefited the world immensely. I seem to recall reading what one respectfull person said about Excel in this thread.
Definitely counter-productive to making money. Your code will be
unusable on any other platform. By using proper standards you will
preserve the ability to move it unchanged in future, and will
protect yourself against the vagaries of Micro$loth. Limit the
non-standard things to isolated specific system dependant files.
Don't use such things as stdafx.h, just to save typing a few
#include lines.
Even today, your actions are cutting you off from the Linux, Unix,
and Mac worlds, not to mention the much larger embedded world.
If nothing else the non-standardisms preclude your asking for help
here, because the readership generally does not understand them, or
will act in that manner on principle.
--
"Our enemies are innovative and resourceful, and so are we.
They never stop thinking about new ways to harm our country
and our people, and neither do we." -- G. W. Bush.
"The people can always be brought to the bidding of the
leaders. All you have to do is tell them they are being
attacked and denounce the pacifists for lack of patriotism
and exposing the country to danger. It works the same way
in any country." --Hermann Goering.
On 2006-06-05, jaysome <ja*****@spamco p.net> wrote: On Sun, 04 Jun 2006 00:05:04 -0400, CBFalconer <cb********@yah oo.com> wrote:
Don't let yourself be brain washed by Micro$loth. scanf has NOT been deprecated. scanf_s is NOT a method, it is a non-standard function. There is a draft technical report n1146.pdf describing these things.
Using such non-standard things, and such other non-standards as stdafx.h, only locks your code into the Micro$oft way and is counter-productive.
Counter-productive to what? Surely not to making money, as you so openly imply by using terms that begin with "Micro$". Microsoft has allowed a lot of people to make money. And at the same time they've made money themselves and have benefited the world immensely. I seem to recall reading what one respectfull person said about Excel in this thread.
It can be beneficial, sometimes, to reflect upon the past and reconsider it in the present. Such a relection may lead to newly discovered insights, however that may be hard to swallow juxtaposed against past beliefs.
This group is about C not about making money using MS tools.
Plus, I'm pretty sure that last year a lot of companies lost a lot
of money because of the viruses. You can also consider the loss of
the companies locked out of the market because of the monopolistic
behavior of MS.
But this is c.l.c. So, the problem is not the money. :-)
--
Ioan - Ciprian Tandau
tandau _at_ freeshell _dot_ org (hope it's not too late)
(... and that it still works...)
To compute nCr effectively, pre-compute 1/2 of Pascal's triangle.
Here is a sample where nCr has been pre-comuted for n,r up to 1000: http://cap.connx.com/chess-engines/n...oach/pas.c.bz2
Most compilers won't even be able to compile it (it violates several
standard limits). However GCC 4.1 under Linux can hadle it just fine.
On Sat, 03 Jun 2006 16:24:38 -0700, Schizoid Man <sc***@sf.com > wrote: Any ideas?
It has nothing to do with C, and everything to do with a fundamental problem with radix
notation and the fact that not all values can be perfectly represented in finite-length
radix representation for all integer radices.
(In your case, there is no exact representation of decimal 0.1 in binary radix notation.
<ftp://ftp.quitt.net/outgoing/goldbergFollowu p.pdf>
--
#include <standard.discl aimer>
_
Kevin D Quitt USA 91387-4454 96.37% of all statistics are made up
"Schizoid Man" <sc***@sf.com > wrote in message
news:e5******** **@geraldo.cc.u texas.edu... Coos Haak wrote:
On another note, can you tell me why the following method are not giving me Combination results over 12? The following program works fine till 12 and then mysteriously blows up.
12 factorial can fit in 32 bits. 13 factorial won't.
Hi Coos,
I figured that out, albeit after I posted my message.
The function I'm trying to evaluate is Combin(n,r) = factorial(n) / (factorial (n-r) * factorial (r)).
For some reason, C is blowing up for numbers like Combin(350,170) , whereas Excel is computing these large numbers quite easily. Any suggestions?
A few days ago, I posted a link to a combination table for combinations up
to 1000 elements.
I tweaked it a bit so that it should compile on just about any system now.
If some constant blows your compiler's mind, you can cut off the
computations at that point. Certainly Combin(350,170) will not pose a
problem. http://cap.connx.com/chess-engines/n...oach/pas.c.bz2
The compressed source code is 15 MB, but you can cut it back to only the
size that you need.
Here is the program that generates the tables: http://cap.connx.com/chess-engines/n...pascal.exe.bz2
You can use it to generate the 1/2 Pascal's triangle data for any set size
you like.
It uses a library called MIRACL to generate the tables (it is an extended
precision rational number C++ class library). This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Amit Bhatia |
last post by:
Hi there.
I am cross posting this on comp.lang.c as well: sorry for same.
The problem I am facing is as follows:
For example:
double a= 0.15;
double b=2.4;
const double VERYTINY =1.e-10;
I know b/a = 16 and hence the remainder is zero; but I am not
able to find any suitable thing to encode it into in c.
for example (fmod(b,a)>VERYTINY) returns true!
|
by: Pushkar Pradhan |
last post by:
I tried to read the archives and solve this problem, but now I think I
better post my problem:
int main() {
int blkSz = { {2,2},
{2,3},
.....,
{6,6} };
write_bc_perf(mflops1, blkSz, NUMBASECASES);
|
by: Shawn |
last post by:
Hello all,
I apologize as I am sure this has probably been dealth with before...
but I am doing an exercise from "Practical C Programming" and I have
been unable to get it to work perfectly due to problems with floating
point arithmetic and I am looking for a way to solve it. See the code
below...
Given a certain amount of change (below $1.00) the program will tell
you how many of each coin you will need to get that amount. The
program...
|
by: TTroy |
last post by:
Hello, I'm relatively new to C and have gone through more than 4 books
on it. None mentioned anything about integral promotion, arithmetic
conversion, value preserving and unsigned preserving. And K&R2
mentions "signed extension" everywhere.
Reading some old clc posts, I've beginning to realize that these books
are over-generalizing the topic. I am just wondering what the
difference between the following pairs of terms are:
1)...
|
by: PDHB |
last post by:
I'm sorry, but this is just the height of stupidity.
I love the dot net framework. It has actually been sufficient to convert an
anti-microsoft extremist (myself) to the windows camp. But not having
numerical value types inherit from an interface to allow for arithmetic in
generics, or in some other way allow arithmetic in generics without a
performance killing or ugly work around is just the epitomy of idiocy.
Yes, microsoft today is...
| |
by: Tom |
last post by:
I have a VB.NET framework 1.1 application that I am installing on my user's
workstation. It works fine on EVERY machine except for one - on this one
machine it generates a 'Overflow or underflow in the arithmetic operation'
when I attempt to instantiate my first form, as so:
Dim frm As New frmMyForm()
Based on some things I saw here, I thought it might be that this workstation
didn't have a MS Sans Seriff font on it (since that is the...
|
by: Bill Reid |
last post by:
Bear with me, as I am not a "professional" programmer, but I was
working on part of program that reads parts of four text files into
a buffer which I re-allocate the size as I read each file. I read some
of the items from the bottom up of the buffer, and some from the
top down, moving the bottom items back to the new re-allocated
bottom on every file read.
Then when I've read all four files, I sort the top and bottom items
separately...
|
by: jdcrief |
last post by:
I have all of this program working except for the pointer arithmetic
part, I think. This program should average the student's grades
together using pointer arithmetic and then display the student's and
their average grade. I do know that I will need to delete the array to
avoid a memory leak, but I am stuck on this part of the program. I am
open to any suggestions.
#include "stdafx.h"
#include <iostream>
#include <stdio.h>
|
by: mmm |
last post by:
I wrote the code below to create simple arithmetic sequences that are
iter-able
I.e., this would basically combine the NUMPY arange(start,end,step)
to range(start,end), with step not necessarily an integer.
The code below is in its simplest form and I want to generalize the
sequence types (multiplicative, cumulative, gauss ...), but first I
need the simple SEQA( ) function to be more robust. The problem is
the three test code...
|
by: Selvam |
last post by:
Hi All,
I am getting exponent value when doing float arithmetic in C++.
Instead of that I need accurate value.
float amount = 0.0f;
float x = 0.99999976f;
amount= 1.0f - x;
I am getting amount as 2.3841858e-007 instead of 0.00000024
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
| |
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |