I'm wondering if anyone can give any advice on tracing a rounding error in a program.
I have two slightly different implementations of a process, which basically come down to the following.
In Version 1, various increments are added to a double variable, and at the end I check to see if it is...
Does anyone have any comments on which of these pieces of code will run more efficiently?
In these code examples, check is a variable of type bool (it is an actual variable, not an expression that is reevaluated each time the if() statement is run), and i and N are unsigned ints.
if(check) {...
I've started introducing some C++ modules to my code project (scientific number-crunching), where it's convenient to do so, and have been following the instructions at http://www.parashift.com/c++-faq-lite/mixing-c-and-cpp.html for mixing code.
A few things are niggling me, mostly trivial, but...
Is there a maximum array length in C, other than the size of the computer's memory?
... and ... are there any functions in the standard library which might tell you the length of an array (other than strlen(), which I know about)?
Hello all,
For my code work up until now (scientific number-crunching) I have used C, but there are a handful of cases where it would be useful to have some object-oriented programming (e.g. for simulation of traders bidding on a stock market, or similar multi-agent work).
I've dealt with this...
As per my previous thread I went away and came up with a set of functions to help with data input. Unfortunately a segmentation fault is now showing up, apparently due to one of these functions, and I can't work out why.
Here's the code:
#include <stdio.h>
#include <stdlib.h>
#include...
Hello all,
I've been trying to work out how to dynamically input strings---i.e. to be able to input a string without first deciding what size it should be. Here's a test program:
/* iotest.c */
#include <stdio.h>
#include <stdlib.h>
int main(void) {
int i, stringsize;
char info1[127]...
I have a C program which basically does the following:
(1) Prints a load of questions and scanf()'s responses
(2) Runs a simulation based upon the input, and prints out numbers on the screen (1, 2, 3, ...) using printf() to let me know how it's progressing.
What I often do is suspend the job...
Hello all,
One of the functions I use in my code is a modified form of a module in the GNU Scientific Library, which follows this post.
Note that the "seed" for the random number sequence is contained in the variables x_ran2, y_ran2, n_ran2, shuffle_ran2.
Now, this is a module, so... these...
Hello all,
I've got a warning coming up in some code that I don't understand (the subject line should tell you what it is:-)).
The lines in question are implementations of the following macros that I've written as a very simple mechanism for code to exit gracefully in the event of a memory...
Hello all,
I'm trying to set up Cisco VPN client 4.6 to allow me to connect to my university network remotely. My OS is SUSE Linux 10.0.
The actual software is installed, and, as root or superuser, I can log onto the VPN, which gives me a university IP address via the connection cipsec0. (I...
Hello all,
I'm running SuSE 10.0 on my laptop, and I have clamAV installed on there. However, I'd like to get antivirus stuff a bit more friendly. On Windows I use NOD32 and if I could get something for Linux with the same functionality and ease of use, I would be a happy bunny.
In...
Hello all,
A project necessity has come up which, to be honest, I have no idea how to start working on, so I thought I'd ask here. :-)
The problem is this: we need to write a program that will read from the serial port and forward to a virtual port of our choosing. Of course, it's not just...
Hello all,
I'm using SuSE Linux 10.0 with KDE 3.4.2 Level "b" on my Dell Inspiron laptop.
The keyboard layout is United Kingdom, and this works fine; but I have found it impossible to have an easy way to switch between the basic and international variants of this layout. Most of the time the...
Hello all,
I've just installed SUSE 10.0 on my laptop in dual boot with XP. Previously I had Ubuntu 5.10 installed...
In general it seems very nice but I have a couple of problems---one irritating, the other a bit more serious.
The serious one is to do with setting up Thunderbird. I managed...
Hello all,
I've heard that it's good practice to always declare char variables as signed or unsigned.
Could anyone comment? Is it worth it?
In addition, under what circumstances should one declare one or the other?
I note that when I tried to compile a program under Linux with all unsigned...
Hello all,
I've been adapting some code from the GNU Scientific Library (GSL) for my own evil purposes. The following is a random number generator "ran1" (same algorithm as found also in Numerical Recipes for C):
#define N_SHUFFLE 32
#define N_DIV (1 + 2147483646/N_SHUFFLE)
static const...
Further to my previous question about modularizing code, when I want to compile source to object files, is there any way of determining where the object files are located?
e.g. gcc -c [all the source files] just produces objects in the present directory.
But suppose I wanted to put all the...
Could anyone recommend a really good math library for C?
I note that the standard math.h library often takes variable values as input. My practice is where possible to pass pointers to functions. Do all these maths functions really need to use the passed data destructively? Is there a math...
Hello,
Suppose I wanted to split my code into separate modules, as is quite common for large applications. I'm talking about the sort of thing where one compiles,
gcc file1.c file2.c file3.c -o bigfile
What sort of effect does this have on performance? Does it improve or harm things? I'm...
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.