Programming :: Absoulte Value Of A Floating Number?

Jan 10, 2011

I try to get the absolute value of a floating number but i could not until now. I am using bash script btw.lets say A is a floating number:A=-0.125

Code:
absA=$(echo '$A' | nawk '{print ($1>=0)? $1:0-$1}')
the above code gives absA=0, whereas

[code]....

View 2 Replies


ADVERTISEMENT

Programming :: Force A Floating Point To Show More 0s?

Sep 9, 2010

I am dealing with money and I don't want it to show $.1, I'd rather it show $.10 Is there a way to change this in C++?

View 4 Replies View Related

Programming :: Operator For Floating Point Comparison?

May 10, 2011

I know it is wrong to use the "==" operator to compare the equality of two floating point numbers. Logically it would seem that if the "==" operator is not usable for floating point comparison, then the "<=" operator would also not be usable. Is this true? The lack of google search results on this topic made me think that it must be true. If that is true, then is it true that the only way to compare floats with <= or >= is with something like the code below? Code: bool smaller_than_or_equal(float a, float b) {

if ( fabs(a-b) < EPSILON){return true;}
else if (a < b) {return true;}
else {return false;}

} I think this is a general question, but if specifics are necessary, I am using the C++ language to code at the moment.

View 5 Replies View Related

Programming :: IEEE Floating Point Format?

Jun 5, 2011

I'm reading a book on assembly, and it talks a bit about the IEEE floating point format.

Quote:

To summarize, the following steps are used to convert a decimal number to IEEE single format: 1. The leading bit of the floating point format is 0 for a positive number and 1 for a negative number. 2. Write the unsigned number in binary. 3. Write the binary number in binary scientific notation f23.f22 ... f0 2^e, where f23 = 1. There are 24 fraction bits, but it is not necessary to write trailing 0's. 4. Add a bias of 127 to the exponent e. This sum, in binary form, is the next 8 bits of the answer, following the sign bit. (Adding a bias is an alternative to storing the exponent as a signed number.) 5. The fraction bits f22f21 ... f0 form the last 23 bits of the floating point number. The leading bit f23 (which is always 1) is dropped.

View 1 Replies View Related

Programming :: Fortran Runtime Error: Bad Value During Floating Point Read

Jun 28, 2011

I am getting error Fortran runtime error: Bad value during floating point read. How do I format negative sign?

[code]...

View 1 Replies View Related

Programming :: Perform Floating Point Operations In Linux Kernel?

Apr 7, 2011

how to perform floating point operations in kernel? i answered that its impossible to perform floating point operations in kernel.but he is telling that its possible but with some feature to be added.can any body know about this perfectly??

View 1 Replies View Related

Programming :: Octave - Load A Text File With Floating Point Values Into A Matrix?

Jan 29, 2011

I have a .txt file with the format

0.01
0.04
0.07
...
0.83

I am wanting to load this into octave and perform operations on the data.

[Code]...

View 2 Replies View Related

Programming :: Length Of "Options" Field In TCP Header Is Floating?

May 31, 2011

As you know, the length of "Options" field in TCP header is floating. It may be from 0 to 40 bytes. Is there any (simple) way to find it or to send data with TCP headers of fixed length?

View 8 Replies View Related

Programming :: Invoke The Calculator "bc" In Bash Script For Floating Point Arithmetic?

May 15, 2010

My main problem right now is doing floating point arithmetic within a bash script, with variables.Right now I have a folder called "myExamples" with a script called "run_example" that runs with no issues.I plan to(1) create many folders inside [myExamples], that are named [example10] [example11]...each containing an identical copy of (run_example),(2) modify Line 172 of each copy of (run_example)...in one copy, it would be 3.00, the next copy would have 3.05, etc. (This part doesn't work!)How can use the available calculator bc code to do floating point operations?My code is below -

#!/bin/sh
# run from directory where this script is
cd `echo $0 | sed 's/(.*)/.*/1/'` # extract pathname

[code]...

View 2 Replies View Related

Programming :: Asm 64bit Registers - "64-bit Linux Allows Up To Fourteen Parameters To Be Transferred In Registers (6 Integer And 8 Floating Point)."

Mar 28, 2010

I have tried to learn how 64bit asm (nasm in my case) works and found, among the many disparate pieces of info on the net, a few vague inferences that floating point registers can be used for other purposes than what they are intended for, example: "64-bit Linux allows up to fourteen parameters to be transferred in registers (6 integer and 8 floating point)." This would be fantastic for string operations/manipulation (I have never used asm for floating-point operations), can anyone shed a bit of light?

View 8 Replies View Related

Programming :: Get A Number Between Two Numbers?

Feb 1, 2010

I have some code that opens a directory and reads in the names of files which are e.g. 0001, 0002, 0003 up to 9999I need to get all these numbers and then generate a new number that is not one of these numbers already.here is my code to check the files in the directory

DIR *d;
struct dirent *dir;
int i = 0;

[code]....

View 11 Replies View Related

Programming :: How To Get A Unicode Number

Jul 7, 2011

But what is the easiest way to figure out the Unicode number of a character when you already have the character?

For instance, I pasted this character here from a PDF:

View 4 Replies View Related

Programming :: How To Get Number Of Cores Using C?

Apr 13, 2011

Anybody knows How can I get the number of cores of a machine?I know that I can use POPEN and get the stream of this:

Code:
grep -i 'processor' /proc/cpuinfo | wc -l
But, I think that a simple method to do this.

View 10 Replies View Related

Programming :: Get Random Number From -1 To 1 In C?

Mar 4, 2011

i want to generate random number in c programming from -1 to 1

View 1 Replies View Related

Programming :: Grep For Exact Number 0?

Aug 6, 2010

1) I need to search a field value to check for exact 0. If the number is 0, it should throw error.

The line to be searched looks like as below. "Output Rows [1], Affected Rows [1], Applied Rows [1], Rejected Rows [0]"

Here I have to search whether the affected rows is 0. But the code below picks up other values also (lie 10, 20.. etc). How do we write to get an exact match for 0? Code: affected=`echo ${line} | cut -f6 -d" " `

affectedcount='echo ${affected} |grep 0 ` 2) Also, I need to check whether the rejected rows > 0
Code: rejected=`echo ${line} | cut -f12 -d" " `
rejectedcount='echo {rejected} |grep [1-9]`

3)Can we combine these two statements in a better way to get the desired results?

View 2 Replies View Related

Programming :: Check If The Variable Is A Number Or Not

Apr 30, 2011

I've created (as a homework) to create as many folders as told but I still need to check if the variable is a number or not :

Code: #!/bin/sh
echo "Veuillez saisir un nombre"; read nmbr
nmbrf=$nmbr
while [ $nmbrf -gt 0 ]
do mkdir -p "foo$nmbrf"
nmbrf=`expr $nmbrf - 1`
echo "$nmbrf"

how do I check that nmbr is a number or something else?

View 1 Replies View Related

Programming :: Getting Number Of Digits In Uint64_t?

Jul 7, 2011

I'm having a hard time trying to get the number of digits in a uint64_t variable. The reason I'm using this is I want to make sure I get x amount of digits inside of a variable before I use it, but since the higher the digits, the better the program is.I currently use the following code, and it works, but my loop will never exit because the length is always 0:

Code:

/**
* numbdigits()
* number: The number to evaluate [in]
*
* Returns the number of digits found in a number.

[code]....

getrand() returns a uint64_t as well (and works). The only way the while() loop ends without my intervention is if I do curd += numdigits(val) instead...but, that gives a false value as well.

View 7 Replies View Related

Programming :: Get The Number Of Elements In A Char*[] In C++?

Jan 27, 2011

I have a char*[] array:

Code:
char* myarray[] = {"Hello", "there!", "LQ"};

and I wish to use/ write a function to find the number of elements in myarray (in this case, its 3).

*equivalent of .NET's array.size() that returns number of elements in array

How do I achieve it?

View 7 Replies View Related

Programming :: Grab One Number From A Row In Text But Not Another?

Apr 23, 2009

I have a text file that contains the following string of numbers and letters:

Code:
Mean track length: 3.45 +/- 1.23 mm
or

Code:
Mean track length: 22.45 +/- 12.23 mm

In the first example, I would like to grab only 3.45 and write it into a new file. Then I would like to grab only 1.23 and write it into another file.
I have 80,000 files to do and those numbers can be different every time.

View 9 Replies View Related

Programming :: How To Run Code On Certain Line Number In AWK?

May 9, 2010

I want to be able to run a piece of AWK code on a record specified by number, not by a regex.

View 6 Replies View Related

Programming :: Php Can Recognize The Number Of Words?

Jun 16, 2010

User submits a ms word file, and the php can recognize the number of words? Is it only possible for ms win server?

View 1 Replies View Related

Programming :: Get Information About Description Number Usb Device

May 10, 2011

How can I know what number descriptor is used by my usb device indicate via libusb_device_handle structure ? I can't find declaration of libusb_device_handle structure. I need this information to use poll() function where I need decripttion number of device.

View 1 Replies View Related

Programming :: Get Information About Description Number Usb Device?

May 10, 2011

How can I know what number descriptor is used by my usb device indicate via libusb_device_handle structure ? I can't find declaration of libusb_device_handle structure. I need this information to use poll() function where I need decripttion number of device.

View 4 Replies View Related

Programming :: Bash Subtract Negative Number Using Bc

May 15, 2011

How can i get bc to subtract negative numbers?

View 10 Replies View Related

Programming :: C - Initialize An Undetermined Number Of Variables?

Feb 3, 2010

In C, how can I declare multiple variables at once where the number that needs to be declared is unknown to the programmer.For example, a program that needs to declare some number of integers, but the user will tell the program how many integers to declare. Such as:
x1
x2
x3
x4
x5
.
.
.
Where the programmer doesn't know how many need to be declare you setup theinitialization?

View 11 Replies View Related

Programming :: C: Sscanf But Number Of Variables Unknown?

Nov 29, 2010

Goal:assign integers into array form string.

From string
"123,456,789,0123,4567,8901" (comma separated 6 integer numbers)
To array

[code]....

View 2 Replies View Related

Programming :: Command For Seeing Number Of Threads Running?

Jun 8, 2011

IS there any command to see number of threads are running in a process .I have check ps -eLf but it wont show display for all the threads

View 1 Replies View Related

Programming :: Convert A Variable Number In Megabytes?

Feb 22, 2010

Code:
FILE_SIZE=`find /var/logs/ -type f -mtime +5 | wc -c`
im trying to convert FILE_SIZE into megabytes

[code]....

View 8 Replies View Related

Programming :: Write A Script Which Will Get A Number From STDIN?

Dec 15, 2008

I need to write a script which will get a number from STDIN and then with that number echo a set number of questions (its for a firewall config). Heres what I want the user to receive.

How many ports do you want open? 3

1. specify port: 80
2. specify port: 21
3. specify port: 23

In the background this will echo a command out to a text file which will read as follows:

open port 80
open port 21
open port 23

I've done this before but I've completely forgotten how

View 2 Replies View Related

Programming :: Get Number Of Elements In A Hash Of Arrays?

Dec 10, 2008

I have something like this:

$arr_hash{'produce'}{'veggies'}[0] = Broccoli
$arr_hash{'produce'}{'veggies'}[1] = Cauliflower
$arr_hash{'produce'}{'veggies'}[2] = Carrots

[code]...

View 2 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved