Thank you for such a quick and informative reply all of you.
I am apologizing for my ignorance, and am so ashamed because of it.
I am trying to extract a three variables (integer numbers): n31, n32, n33, for a specific value of "f". On top of that there is a third variable "f0" which should vary from 10^-26 to 10^-5.
So what this code should enable me is that for some "f" which I will get from my press machine and read it, I should search this C code for the same (or similar) "f" value, and read what are the values for f0, n31, n32, n33 in accordance to that "f" value.
An example: If I get a value of 5e-10 from my machine press, I will look for the some (or similar value) in C code and when I find that value I will be able to get the f0, n31, n32, n33 from it. Like this:
3.63078e-006 -5.09259e-010 27 27 28
I am I still puzzled why am I getting a negative values for "f" (-5.09259e-010 ?)
This is a structural analysis study of a piston press. The f, f0, n31, n32, n33 are coefficients needed in order for the design calculation to be done. As there are few equations with few variables, it seems writing a C code with loop and then getting the values from it is only available solution, as I did not succeed in calculating these factors by hand.
@std10093: I tried changing the parts of the code the way you told me, like this:
Code:
#include<stdio.h>
#include<math.h>
int main(void){
float f0;
double n31,n32,n33,f;
double A=0.373;
printf("# f0, f, n31, n32,n33\n");
for(f0=1.0e-26;f0<=1.0e-5;f0=f0*pow(10.0,0.02)){
n31=-2.0+floor(1.29*pow(f0,-0.25));
n32=-2.0+floor(A*pow(f0,-0.25)*(12.0)*sqrt((n31+2.0)/(11.0*n31+43.0)));
n33=-2.0+floor(A*pow(f0,-0.25)*(41.5692)*sqrt((n31+2.0)/(11.0*n31+43.0)*(n32+2.0)/(11.0*n32+43.0)));
f=pow(13.5,1.5)*f0*pow(n31+2.0,-2.0)*pow(n32+2.0,-2.0)*(n33+2.0,-2.0);
printf("%g %g %i %i %i\n",f0,f,(int)n31,(int)n32,(int)n33);
}
}
Still the most lower value for "f0" is around 1.2e-011.
And I also run the code you gave me (the one for the maximum value) and got something similar like you:
Code:
1.79769e+308
17976931348623157000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000000000000.000000
Process returned 0 (0x0) execution time : 0.016 s
Press any key to continue.
@Adak. Here is the content of the limits.h file I found in "C:\Dev-Cpp\include" folder. What part of it do I need to change in order to increase that lower limit of 1.2e-011?
Code:
/*
* limits.h
* This file has no copyright assigned and is placed in the Public Domain.
* This file is a part of the mingw-runtime package.
* No warranty is given; refer to the file DISCLAIMER within the package.
*
* Functions for manipulating paths and directories (included from io.h)
* plus functions for setting the current drive.
*
* Defines constants for the sizes of integral types.
*
* NOTE: GCC should supply a version of this header and it should be safe to
* use that version instead of this one (maybe safer).
*
*/
#ifndef _LIMITS_H_
#define _LIMITS_H_
/* All the headers include this file. */
#include <_mingw.h>
/*
* File system limits
*
* TODO: NAME_MAX and OPEN_MAX are file system limits or not? Are they the
* same as FILENAME_MAX and FOPEN_MAX from stdio.h?
* NOTE: Apparently the actual size of PATH_MAX is 260, but a space is
* required for the NUL. TODO: Test?
*/
#define PATH_MAX (259)
/*
* Characteristics of the char data type.
*
* TODO: Is MB_LEN_MAX correct?
*/
#define CHAR_BIT 8
#define MB_LEN_MAX 2
#define SCHAR_MIN (-128)
#define SCHAR_MAX 127
#define UCHAR_MAX 255
/* TODO: Is this safe? I think it might just be testing the preprocessor,
* not the compiler itself... */
#if ('\x80' < 0)
#define CHAR_MIN SCHAR_MIN
#define CHAR_MAX SCHAR_MAX
#else
#define CHAR_MIN 0
#define CHAR_MAX UCHAR_MAX
#endif
/*
* Maximum and minimum values for ints.
*/
#define INT_MAX 2147483647
#define INT_MIN (-INT_MAX-1)
#define UINT_MAX 0xffffffff
/*
* Maximum and minimum values for shorts.
*/
#define SHRT_MAX 32767
#define SHRT_MIN (-SHRT_MAX-1)
#define USHRT_MAX 0xffff
/*
* Maximum and minimum values for longs and unsigned longs.
*
* TODO: This is not correct for Alphas, which have 64 bit longs.
*/
#define LONG_MAX 2147483647L
#define LONG_MIN (-LONG_MAX-1)
#define ULONG_MAX 0xffffffffUL
/*
* The GNU C compiler also allows 'long long int'
*/
#if !defined(__STRICT_ANSI__) && defined(__GNUC__)
#define LONG_LONG_MAX 9223372036854775807LL
#define LONG_LONG_MIN (-LONG_LONG_MAX-1)
#define ULONG_LONG_MAX (2ULL * LONG_LONG_MAX + 1)
/* ISO C9x macro names */
#define LLONG_MAX LONG_LONG_MAX
#define LLONG_MIN LONG_LONG_MIN
#define ULLONG_MAX ULONG_LONG_MAX
/* MSVC compatibility */
#define _I64_MIN LONG_LONG_MIN
#define _I64_MAX LONG_LONG_MAX
#define _UI64_MAX ULONG_LONG_MAX
#endif /* Not Strict ANSI and GNU C compiler */
#endif /* not _LIMITS_H_ */
From the above code:
Code:
#define PATH_MAX (259)
Is that what I need to change/increase ??
Thank you.