10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
I am using bash
I have a script that takes a number, i.e. 85.152, which is always a non integer and essentially tries to get that number to be a multiple of 10. My code is as follows:
number=85.152
A=${number%.*} #Converts float to integer
typeset -i B=$(((A-20)/10)) #subtracting 20 is... (12 Replies)
Discussion started by: prodigious8
12 Replies
2. Shell Programming and Scripting
Hi everyone,
I'm having some trouble with float array.
When i try to get the array sum with float numbers i get this error line 39: soma + 2.34 | bc: syntax error: invalid arithmetic operator (error token is ".34 | bc")
26 Somar() {
27 echo "Quantos numeros deseja somar?"
28 read... (4 Replies)
Discussion started by: berveglieri
4 Replies
3. Shell Programming and Scripting
I have a file with 2 columns . One of the line looks like the following.
Is it possible to convert every float no in column 2 to integer.
input
NM_032881 6.03787973608527e-05
output
0.0000603787..... (2 Replies)
Discussion started by: quincyjones
2 Replies
4. Programming
i am adding two floating point numbers and i want to store in a character pointer...
float f1 ;
float f2 ;
char *c = NULL;
printf("Enter 2 floating numbers\n");
scanf("%f %f",&f1,&f2);
f1 = f1+f2;
sprintf(c, "%f", f1 );
when i execute this, i am... (3 Replies)
Discussion started by: pgmfourms
3 Replies
5. Programming
Hi, i have a simple control like this:
if(sum>1.0)...
If i try to print sum i get 1.000000 but the check returns true. I think it depends on float precision. How can i modify the check?
thanks (1 Reply)
Discussion started by: littleboyblu
1 Replies
6. Shell Programming and Scripting
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
7. Shell Programming and Scripting
how to input float data type in bash shell programming in linux?
I am new to it so unaware to use the commands plz help me out.
thank you. (6 Replies)
Discussion started by: purva
6 Replies
8. Programming
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
9. UNIX for Dummies Questions & Answers
As expr is used for integer calculations, which command is used for float calculations. (1 Reply)
Discussion started by: sharmavr
1 Replies
10. Shell Programming and Scripting
I had a variable 1:80 8 in one varialbe say var=1:80 8
i comapred the below
if
then
--
else
----
thought if condition is true its always going in the else condition....its not giving any compilation errror also....is there any problem bcoz of space...
can some one help... (3 Replies)
Discussion started by: mkan
3 Replies