10-26-2012
Compiler is gcc 4.5.2 on Solaris11 Box
It prints fine however given the 2 different formulas it prints 2 different results.
kilometers = 1.609 * (miles + yards / 1760.0);
end result = A marathon is 42.185970 kilometers.
kilometers1 = 1.609 * (miles + yards / 1760);
end result = A marathon is 41.834000 kilometers.
From what I gather when yards is divided by a float it results in a float.
When yards is divided by an int it results in a int
As a float 385/1760 = .218
As an int .218 = 0
9 More Discussions You Might Find Interesting
1. Programming
Alright, umm i cant get this to work.
im looking at some example and a book i have.
when i try to compile my program i get an error message.
ld: 0711-317 ERROR: Undefined symbol: .sqrt
ld: 0711-345 Use the -bloadmap or -bnoquiet option to obtain more information. I did #include<math.h> after my... (2 Replies)
Discussion started by: primal
2 Replies
2. Programming
Hi, I got an easy problem for you but really difficult for me 'cause I am pretty new to this field
I got header file <math.h> included in my .c file , then I write the code as below:
k = sqrt(i); /* both variables k and i are int */
then I cc temp.c
it says like this
undefined... (4 Replies)
Discussion started by: blf0
4 Replies
3. Programming
I want to calculate secant method using C language
That is a program---->
#include<stdio.h>
#include<math.h>
#include<stdlib.h>
main()
{
double fx(double x);
double x0,x1,x2,f0,f1,f2,err;
int n,i;
printf("\n\n f(x) =x*x*x-5*x-7");
printf("\n\nEnter an interval in"
... (4 Replies)
Discussion started by: cdfd123
4 Replies
4. Programming
Hey all,
How do I link the math library in a gnu make makefile? I have tried using -lm with the CFLAGS varibale - flags like -Wall and -ggdb work, but -lm does not. I am running gcc - 4.1.2 on a linux machine. (2 Replies)
Discussion started by: kermit
2 Replies
5. UNIX for Dummies Questions & Answers
I have 2 variables
a=2
b=1
i want to add a and b
how do i do this in unix using just the echo command and by assigning it to a different variable like c? (13 Replies)
Discussion started by: khestoi
13 Replies
6. Shell Programming and Scripting
$ x=1
$ y=1.5
$ z=$((x*y))
bash: 1.5: syntax error: invalid arithmetic operator (error token is ".5")
What's wrong? (2 Replies)
Discussion started by: rockbike
2 Replies
7. Shell Programming and Scripting
I am trying to do some math, so that I can compare the average of six numbers to a variable.
Here is what it looks like (note that when I divide really big numbers, it isn't a real number):
$ tail -n 6 named.stats | awk -F\, '{print$1}'
1141804
1140566
1139429
1134210
1084682
895045... (3 Replies)
Discussion started by: brianjb
3 Replies
8. UNIX for Dummies Questions & Answers
I am struggling with scripting this challenge a friend and I have.
You have file1 and its contents is a single number
you have file 2 and its contents are a different number
you want to add file1 to file2 and have the output be put into file3 (3 Replies)
Discussion started by: minkyboodle
3 Replies
9. UNIX for Dummies Questions & Answers
i have file (my_file.txt) that looks like this:
000000000000010000
000000000000010000
000000000000005000
000000000000005000
000000000000005000
000000000000005000
000000000000005000
000000000000005000
000000000000005000
000000000000005000
all said and one, it should look... (11 Replies)
Discussion started by: lawsongeek
11 Replies
LEARN ABOUT OPENSOLARIS
vz_pow_
vz_pow_(3MVEC) Vector Math Library Functions vz_pow_(3MVEC)
NAME
vz_pow_, vc_pow_ - vector complex power functions
SYNOPSIS
cc [ flag... ] file... -lmvec [ library... ]
void vz_pow_(int *n, double complex * restrict z,
int *stridez, double complex * restrict w, int *stridew,
double complex * restrict u, int *strideu,
double * tmp);
void vc_pow_(int *n, float complex * restrict z,
int *stridez, float complex * restrict w, int *stridew,
float complex * restrict u, int *strideu,
float * tmp);
DESCRIPTION
These functions evaluate the complex function z^w for an entire vector of values at once. The first parameter specifies the number of val-
ues to compute. Subsequent parameters specify the argument and result vectors. Each vector is described by a pointer to the first element
and a stride, which is the increment between successive elements. The last argument is a pointer to scratch storage; this storage must be
large enough to hold 3 * *n consecutive values of the real type corresponding to the complex type of the argument and result.
Specifically, vz_pow_(n, z, sz, w, sw, u, su, tmp) computes u[i * *su] = (z[i * *sz])^(w[i * *sw]) for each i = 0, 1, ..., *n - 1. The
vc_pow_() function performs the same computation for single precision data.
These functions are not guaranteed to deliver results that are identical to the results of the cpow(3M) functions given the same arguments.
USAGE
The element count *n must be greater than zero. The strides for the argument and result arrays can be arbitrary integers, but the arrays
themselves must not be the same or overlap. A zero stride effectively collapses an entire vector into a single element. A negative stride
causes a vector to be accessed in descending memory order, but note that the corresponding pointer must still point to the first element of
the vector to be used; if the stride is negative, this will be the highest-addressed element in memory. This convention differs from the
Level 1 BLAS, in which array parameters always refer to the lowest-addressed element in memory even when negative increments are used.
These functions assume that the default round-to-nearest rounding direction mode is in effect. On x86, these functions also assume that the
default round-to-64-bit rounding precision mode is in effect. The result of calling a vector function with a non-default rounding mode in
effect is undefined.
Unlike the c99 cpow(3M) functions, the vector complex exponential functions make no attempt to handle special cases and exceptions; they
simply use textbook formulas to compute a complex exponential in terms of real elementary functions. As a result, these functions can raise
different exceptions and/or deliver different results from cpow().
ATTRIBUTES
See attributes(5) for descriptions of the following attributes:
+-----------------------------+-----------------------------+
| ATTRIBUTE TYPE | ATTRIBUTE VALUE |
+-----------------------------+-----------------------------+
|Interface Stability |Committed |
+-----------------------------+-----------------------------+
|MT-Level |MT-Safe |
+-----------------------------+-----------------------------+
SEE ALSO
cpow(3M), attributes(5)
SunOS 5.11 14 Dec 2007 vz_pow_(3MVEC)