Sponsored Content
Full Discussion: Printing float values in C
Top Forums Programming Printing float values in C Post 302725099 by Corona688 on Thursday 1st of November 2012 04:59:17 PM
Old 11-01-2012
Your program does not compile. What is "1/W.CR" supposed to be? That is not valid C.

Ever heard the old adage "measure with micrometer, mark with chalk, cut with axe"? Not even pi is accurate here, you're not going to get anything fantastic out.

You can force scientific notation with %e. From man 3 printf:

Code:
       e, E   The  double  argument  is  rounded  and  converted  in the style
              [-]d.ddde+-dd where there is one digit before the  decimal-point
              character and the number of digits after it is equal to the pre-
              cision; if the precision is missing, it is taken as  6;  if  the
              precision  is  zero,  no  decimal-point character appears.  An E
              conversion uses the letter E (rather than e)  to  introduce  the
              exponent.   The exponent always contains at least two digits; if
              the value is zero, the exponent is 00.

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

comparing two float values

I am trying to compare 2 float values using if the foll code does not work a=1.4 b=1.6 if test $a -gt $b then echo "$a is max" else echo "$b is max" fi does -gt work for floating point numbers, if not how do go about for my requirement? can i use bc ? pls help thanks in advance... (2 Replies)
Discussion started by: kavitha
2 Replies

2. UNIX for Dummies Questions & Answers

Dividing float values

Hi I know its a dumb question but can any one please explain me the difference of executing a shell script in the following 2 ways. . script.sh sh script.sh I have a problem if I execute the following code as sh script.sh DB_CNT_ALW=0.20 SCT_VAR=0.05 if ; then echo "== Difference... (3 Replies)
Discussion started by: shash
3 Replies

3. Programming

math.h: float ceilf(float x)

Good morning, I'm testing the use of ceilf: /*Filename: str.c*/ #include <stdio.h> #include <math.h> int main (void) { float ceilf(float x); int dev=3, result=0; float tmp = 3.444f; printf("Result: %f\n",ceilf(tmp)); return 0; } (1 Reply)
Discussion started by: jonas.gabriel
1 Replies

4. Shell Programming and Scripting

SH if statement using FLOAT values

Today I spent longer than I'd like to admit figuring out how to write a Bourne shell IF statement that tests a FLOAT value before executing a block of statements. Here's the solution I found, which invokes bc. Hope this will come in handy for someone: value = testval = if then body... (5 Replies)
Discussion started by: sjepsen
5 Replies

5. UNIX for Advanced & Expert Users

Get Minimun from a Float values

Hi Guys, here is a part of my source code. This part is reponsible to get the minimun of a few values: .......... MAX=0.00 for a in `cat $OFILE` do if then ... (2 Replies)
Discussion started by: Paat
2 Replies

6. UNIX for Advanced & Expert Users

Printing defaulted values

I have written a phyton script that accepts command line arguments. I am setting defaults for some of them if the user does not specify them. However I want to print the user values and the defaulted values seperately. However, once I set the default values, then I cannot use if... (0 Replies)
Discussion started by: kristinu
0 Replies

7. Shell Programming and Scripting

printing two values with TAB in between

Dear friends, I want to print variables' values in certain format where space between two values of variables is "a tab" I tried where I provided "tab" between two varibales. But when it print values on screen its giving me output without spaces in two values. Request you to help me in... (7 Replies)
Discussion started by: anushree.a
7 Replies

8. Programming

Printing values from a class

I have a class and want to print values in MOD using L = new Layer* ; How can I print the values in MOD using this object L??? class Layer { public : Model* MODP; Model* MODS; (1 Reply)
Discussion started by: kristinu
1 Replies

9. Shell Programming and Scripting

Printing $values using awk

Hi All I had requirement where I need to re-order columns in a file by using a control file. here is the ctrl file c1 c2 c3 source file c3 | c1 | c2 a | b| c I should create output file based on the ctrl file columns o/p should look like this c1 | c2 | c3 b| c|a I wrote some... (9 Replies)
Discussion started by: gvkumar25
9 Replies

10. Shell Programming and Scripting

Array not printing values if used in a loop

Hello! I'm making an English to Morse Code translator and I was able to mostly get it all working by looking through older posts here; however, I have one small problem. When I run it it's just printing spaces for where the characters should be. It runs the right amount of times, and if I try... (3 Replies)
Discussion started by: arcoleman10
3 Replies
J0(3)							   BSD Library Functions Manual 						     J0(3)

NAME
j0, j0f, j1, j1f, jn, jnf, y0, y0f, y1, y1f, yn, ynf -- Bessel functions of first and second kind LIBRARY
Math Library (libm, -lm) SYNOPSIS
#include <math.h> double j0(double x); float j0f(float x); double j1(double x); float j1f(float x); double jn(int n, double x); float jnf(int n, float x); double y0(double x); float y0f(float x); double y1(double x); float y1f(float x); double yn(int n, double x); float ynf(int n, float x); DESCRIPTION
The functions j0(), j0f(), j1() and j1f() compute the Bessel function of the first kind of the order 0 and the order 1, respectively, for the real value x; the functions jn() and jnf() compute the Bessel function of the first kind of the integer order n for the real value x. The functions y0(), y0f(), y1(), and y1f() compute the linearly independent Bessel function of the second kind of the order 0 and the order 1, respectively, for the positive real value x; the functions yn() and ynf() compute the Bessel function of the second kind for the integer order n for the positive real value x. RETURN VALUES
These routines return values of their respective Bessel functions. For large positive inputs, they may underflow and return +-0. The following applies to y0(), y0f(), y1(), y1f(), yn(), and ynf(). If x is negative, these routines will generate an invalid exception and return NaN. If x is 0 or a sufficiently small positive number, these routines will generate an overflow exception and return -infinity. SEE ALSO
math(3) STANDARDS
The j0(), j1(), jn(), y0(), y1(), and yn() functions conform to IEEE Std 1003.1-2001 (``POSIX.1''). The float versions are extensions. HISTORY
This set of functions appeared in Version 7 AT&T UNIX. BSD
February 18, 2008 BSD
All times are GMT -4. The time now is 06:20 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy