The tag has no wiki summary.

learn more… | top users | synonyms

2
votes
2answers
54 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
29 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
492 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 ...
1
vote
2answers
38 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 ...
0
votes
4answers
77 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
248 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
198 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
401 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 ...
0
votes
2answers
103 views

how to convert 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
159 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
224 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 ...
7
votes
3answers
5k 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
77 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
1k 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. ...
102
votes
15answers
38k 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, ...