The tag has no wiki summary.

learn more… | top users | synonyms

1
vote
1answer
45 views

How do you derive a decimal from a math operation involving a variable?

I'm trying to find derive SCALEFACTOR which is basically 10000/(sum of 4th column in a file). How do I get a decimal from the output? Appreciate any help in advance. #!/bin/bash ...
1
vote
1answer
38 views

Simple floating point benchmark that can be compiled from source?

I am interested in benchmarking some ARM platforms; can anyone suggest a simple benchmark with source code that can be used to benchmark floating point performance? A package such as a .deb file ...
3
votes
2answers
82 views

How do determine whether Linux board is using hardware FPU or not?

I am using an embedded Linux board based on a fairly old Freescale ARM chip. How do I determine whether the Python interpreter there is using the hardware FPU on the chip or not? My /proc/cpuinfo ...
1
vote
1answer
192 views

How can subtract 2 floats which have been extracted from 2 other files with BASH [duplicate]

I'm trying to get the difference between two numbers which I have taken from two files. I think my code will make sense: I've tried to make it work by two different methods, didn't work. What I get ...
1
vote
5answers
94 views

Comparing float values in bash

My if expression always evaluates to TRUE somehow. ROTATION variable is 0.000 or 90.000, a float value or it seems so ROTATION="$(mediainfo --Inform="Video;%Rotation%" $VIDEO$ORIGINALEXTENTION)" echo ...
5
votes
2answers
698 views

Bash limiting precision of floating point variables

In Ubuntu 14.04.1 LTS 64-bit bash I am declearing floating point variables by multiplying floating point bash variables in bc with scale set to 3; however, I cannot get the number of digits after the ...
2
votes
1answer
90 views

Problematic bc calculation in shell script

On Ubuntu 14.04.1 64-bit LTS I am writing a shell script and if I define the start of the sequence used in the for loop with a variable instead of a constant I get really weird behavior and there are ...
1
vote
3answers
221 views

Evaluation an expression and rounding up to three decimals

I have an expression "5+50*3/20 + (19*2)/7" I need to round it up to 3 decimal places. The answer to this is 17.92857142857143. When I use the script below it is giving me 17.928. The answer should be ...
0
votes
2answers
57 views

Convert a float to the next integer up as opposed to the nearest?

The context is there are 2 variables that get divided to a floating point result like so: printf "%0.5f\n" $(echo 305/15 | bc -l) 20.33333 How can I always round up to the next integer i.e. 21? ...
1
vote
1answer
1k views

How to round floating point numbers in shell?

How do I correctly round IEEE 754 floating point numbers on the command line? I want to specify the precision of the output number - the count of fractional digits. Rounding 6.66 to precision 1 ...
0
votes
1answer
94 views

How do I add integer and floating numbers together to keep tally?

I'm just trying to do some simple math that is not turning out that simple. this is what I have tried so far and I have yet to find anything on the google net that combines integer and floating ...
4
votes
3answers
183 views

Arithmetic operations with expr and variables

Why won't this statement work? total=`expr $mPercent / 100 "*" .482 + $fPercent / 100 "*" .518` mPercent is a number as a result of an awk statement, as well as fPercent. I also get "expr: ...
1
vote
1answer
131 views

Rounding float numbers in csh

I have a float number stored in a variable $temp, like 3.046789. How we can round this number with 2 digits precision and the result I need is 3.05. The script I have is a csh script.
0
votes
1answer
209 views

Trying to multiply a float in bash not working [duplicate]

I have this script that is to rescale images to a percentage value #!/bin/bash percent=$1 echo $percent for img in `find *.png`; do echo Processing file $img width=$( mdls $img | grep ...
2
votes
2answers
135 views

How can I tell if floating point arithmetic is performed in hardware or software?

Well, exactly as the title says: How can I tell if floating point arithmetic is performed in hardware or software? I could find the processor's name and Google it, but is there a way to do it in a ...
3
votes
2answers
167 views

Comparing an string by value of a floating number to a number

I wrote the code below: for j in `cat output_10.txt` do dri=`echo $j |cut -d':' -f1` nu=`echo $j |cut -d':' -f2` tot=`echo $j |cut -d':' -f3` fre=`echo $j |cut -d':' -f4` if [ $fre > 2 ] ...
5
votes
5answers
775 views

Why does awk not sum to 0

I have this file and I want to sum all the number in first column. Easy: awk '{s+=$1;print $1,s}' file -0.4157 -0.4157 0.0143 -0.4014 0.5973 0.1959 -0.5679 -0.372 -0.2041 -0.5761 0.7130 0.1369 ...
2
votes
2answers
112 views

Formatting a floating point variable in a SED statement

As part of a makefile recipe, I want to repeatedly adjust a few lines in some text file txt.in. In particular, I want to update, among others, the third line which contains simply two numbers ...
1
vote
4answers
1k views

Error: integer expression expected

I have written a script to determine the Load average on the server as follows: #!/bin/bash loadavg=`top -b -n1 | grep -i load | awk -F, '{print$4}'| awk -F: '{print $2}'` if [ "${loadavg}" -le 1 ...
2
votes
2answers
2k views

Comparison of decimal numbers in bash

My search this morning was about how could I compare two decimal numbers in bash, and I came to this answser: How to compare to floating point number in a shell script. This one, however, doesn't ...
1
vote
1answer
3k views

Divide a variable by a number? [duplicate]

Basically I need to convert centimetres to inches which I am trying to do by diving the area in centimetres by 2.54. But I just cannot get this to work. echo "please enter width and then height" ...
2
votes
2answers
1k views

Remove scientific notation bash script

When I convert MB to GB I'm getting below output. I want this output in normal format. When I use bc I'm getting an error. The text file contains nearly 100 such lines like this. I want to print this ...
1
vote
2answers
1k views

How to round a float value to int in bash

I will get value like 2743410360.320 and I want value like 2743410360 to a variable. I tried INTValueOfGB=$ echo "($gb+0.5)/1" | bc But I am getting (standard_in) 1: syntax error
2
votes
2answers
364 views

Shell script and adding large values in a delimited file problem

I have a script that reads through a delimited file and adds up the 3rd element in the file for each record. For a majority of the data files, this works fine except for one. I have one data file were ...
0
votes
1answer
394 views

Floating point performance in Linux

I've tested Geekbench for my computer for both Windows and Linux. It seems that Linux loses markedly in floating point performance. Is there anything I can do about it? Install an optimization ...
12
votes
3answers
17k views

Bash: Float to Integer

Is this right way of doing float to integer in bash, Or is there any other method ? flotToint() { printf "%.0f\n" "$@" }
3
votes
1answer
103 views

Is floating-point arithmetic distro dependant?

I came across an article in Ars Technica about Raspbian that said the primary interest of the developers of it was that they wanted an OS with fully optimized for its floating-point unit, and since ...
4
votes
1answer
2k views

awk high precision arithmetic

I am looking for a way to tell awk to do high-precision arithmetic in a substitution operation. This involves, reading a field from a file and substituting it with a 1% increment on that value. ...
128
votes
16answers
73k views

How to do integer & float calculations, in bash or other languages/frameworks?

Using echo "20+5" literally produces the text "20+5" What command can I use to get the numeric sum, e.g. 25 in this case. Also, what's the easiest way to do it just using bash for floating point, ...