Sponsored Content
Top Forums Shell Programming and Scripting What's the max integer a variable can hold? Post 302439346 by jim mcnamara on Thursday 22nd of July 2010 09:47:56 AM
Old 07-22-2010
As long as you do not attempt arithmetic operations, a string of numbers can be huge.
Shell arithmetic is limited to signed long 32 bit - +/- 2147483648

awk does double arithmetic - DBL_MAX DBL_MIN in limits.h, usually 15 digits of precision

bc can deal with up to 20 digits of precision.
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

capturing the output of grep as integer variable

Hi, I have an expression using grep and nawk that captures the ID number of a given Unix process. It gets printed to screen but I don't know how to declare a variable to this returned value! For example, ps -ef|grep $project | grep -v grep | nawk '{print $2}' This returns my number. How... (2 Replies)
Discussion started by: babariba
2 Replies

2. Shell Programming and Scripting

Max size of variable

What is the maximum amount of characters that you can have in a varible name in the ksh shell? (1 Reply)
Discussion started by: lesstjm
1 Replies

3. UNIX for Advanced & Expert Users

MAX SIZE ARRAY Can Hold it

Hi, Do anyone know what's the max size of array (in awk) can be store before hit any memory issue. Regards (3 Replies)
Discussion started by: epall
3 Replies

4. UNIX for Dummies Questions & Answers

Converting a String variable into Integer

Hi, I am passing a variable to a unix function. However when I try to assign the value to another variable like typeset -i I_CACHE_VAL=$2 Is this because of String to Integer conversion? I get an error. Please help me with thsi. Thanks (2 Replies)
Discussion started by: neeto
2 Replies

5. UNIX for Dummies Questions & Answers

Subtracting an Integer from a Variable

Hello, I am in following situation.- COUNT=`ls -l | wc -l` echo $COUNT ---> 26 NO_OF_FILES=$COUNT-1 echo $NO_OF_FILES ---> 26-1 Here, I want the output to be 25. How could I do this. It seems simple, but I am not getting it. Please help me. (2 Replies)
Discussion started by: The Observer
2 Replies

6. UNIX for Dummies Questions & Answers

built in variable to hold the name of therunning script...

Hi, I have multiple functions that can be called by any shell script. These functions have inbuilt echo statements to logs their activity into a log file. When I run multiple shell scripts that call these functions, they all log into the same log file and I am not able to differentiate which... (2 Replies)
Discussion started by: new_learner
2 Replies

7. Shell Programming and Scripting

Read Variable From Fille And Convert it to Integer

I read 3 variables from from Inputfile.txt the third one "startnumber" is a number when i compare it with 9 ($startnumber -le 9) it give's me a "unary operator expected", i know that -le is for number comparison. What i need is to convert $startnumber to integer (i have try to do it with expr but... (8 Replies)
Discussion started by: marios
8 Replies

8. Solaris

How to Use a Variable as Integer?

hello, i am writing a script that takes the UID from the PASSWD and then i want to increse the Number by one. for the Next user. i cannot get this to work that a variable is as interger example: set i = 0 set $i = $+1 it's in tcsh if it's mather (10 Replies)
Discussion started by: shatztal
10 Replies

9. Shell Programming and Scripting

Date/Time parts to variable as integer

Hi Guys, i guess there is a several ways to grub the strings from date and time like THISMONTH='/bin/date +%m' but the hard part is to add or sub that string to a variable i tried to use let command TWOMONTHSAGO=$THISMONTH declare -i TWOMONTHSAGO let TWOMONTHSAGO-=2 but there... (1 Reply)
Discussion started by: CyR0iz4l1v3
1 Replies

10. Shell Programming and Scripting

Variable hold in UNIX job

In log directory file contain log files and files contain some unique job name which is dynamically created (example=55555 ),if job get 55555 then send alert message, but after next run if it find ---55555 then no need send alert message While checking the first job name you are capturing the Job... (3 Replies)
Discussion started by: Kalia
3 Replies
FLOAT(3)						   BSD Library Functions Manual 						  FLOAT(3)

NAME
float -- description of floating-point types available on OS X and iOS DESCRIPTION
This page describes the available C floating-point types. For a list of math library functions that operate on these types, see the page on the math library, "man math". TERMINOLOGY
Floating point numbers are represented in three parts: a sign, a mantissa (or significand), and an exponent. Given such a representation with sign s, mantissa m, and exponent e, the corresponding numerical value is s*m*2**e. Floating-point types differ in the number of bits of accuracy in the mantissa (called the precision), and set of available exponents (the exponent range). Floating-point numbers with the maximum available exponent are reserved operands, denoting an infinity if the significand is precisely zero, and a Not-a-Number, or NaN, otherwise. Floating-point numbers with the minimum available exponent are either zero if the significand is precisely zero, and denormal otherwise. Note that zero is signed: +0 and -0 are distinct floating point numbers. Floating-point numbers with exponents other than the maximum and minimum available are called normal numbers. PROPERTIES OF IEEE-754 FLOATING-POINT Basic arithmetic operations in IEEE-754 floating-point are correctly rounded: this means that the result delivered is the same as the result that would be achieved by computing the exact real-number operation on the operands, then rounding the real-number result to a floating-point value. Overflow occurs when the value of the exact result is too large in magnitude to be represented in the floating-point type in which the compu- tation is being performed; doing so would require an exponent outside of the exponent range of the type. By default, computations that result in overflow return a signed infinity. Underflow occurs when the value of the exact result is too small in magnitude to be represented as a normal number in the floating-point type in which the computation is being performed. By default, underflow is gradual, and produces a denormal number or a zero. All floating-points number of a given type are integer multiples of the smallest non-zero floating-point number of that type; however, the converse is not true. This means that, in the default mode, (x-y) = 0 only if x = y. The sign of zero transforms correctly through multiplication and division, and is preserved by addition of zeros with like signs, but x - x yields +0 for every finite floating-point number x. The only operations that reveal the sign of a zero are x/(+-0) and copysign(x,+-0). In particular, comparisons (x > y, x != y, etc) are not affected by the sign of zero. The sign of infinity transforms correctly through multiplication and division, and infinities are unaffected by addition or subtraction of any finite floating-point number. But Inf-Inf, Inf*0, and Inf/Inf are, like 0/0 or sqrt(-3), invalid operations that produce NaN. NaNs are the default results of invalid operations, and they propagate through subsequent arithmetic operations. If x is a NaN, then x != x is TRUE, and every other comparison predicate (x > y, x = y, x <= y, etc) evaluates to FALSE, regardless of the value of y. Additionally, predicates that entail an ordered comparison (rather than mere equality or inequality) signal Invalid Operation when one of the arguments is NaN. IEEE-754 provides five kinds of floating-point exceptions, listed below: Exception Default Result __________________________________________ Invalid Operation NaN or FALSE Overflow +-Infinity Divide by Zero +-Infinity Underflow Gradual Underflow Inexact Rounded Value NOTE: An exception is not an error unless it is handled incorrectly. What makes a class of exceptions exceptional is that no single default response can be satisfactory in every instance. On the other hand, because a default response will serve most instances of the exception satisfactorily, simply aborting the computation cannot be justified. For each kind of floating-point exception, IEEE-754 provides a flag that is raised each time its exception is signaled, and remains raised until the program resets it. Programs may test, save, and restore the flags, or a subset thereof. PRECISION AND EXPONENT RANGE OF SPECIFIC FLOATING-POINT TYPES On both OS X and iOS, the type float corresponds to IEEE-754 single precision. A single-precision number is represented in 32 bits, and has a precision of 24 significant bits, roughly like 7 significant decimal digits. 8 bits are used to encode the exponent, which gives an expo- nent range from -126 to 127, inclusive. The header <float.h> defines several useful constants for the float type: FLT_MANT_DIG - The number of binary digits in the significand of a float. FLT_MIN_EXP - One more than the smallest exponent available in the float type. FLT_MAX_EXP - One more than the largest exponent available in the float type. FLT_DIG - the precision in decimal digits of a float. A decimal value with this many digits, stored as a float, always yields the same value up to this many digits when converted back to decimal notation. FLT_MIN_10_EXP - the smallest n such that 10**n is a non-zero normal number as a float. FLT_MAX_10_EXP - the largest n such that 10**n is finite as a float. FLT_MIN - the smallest positive normal float. FLT_MAX - the largest finite float. FLT_EPSILON - the difference between 1.0 and the smallest float bigger than 1.0. On both OS X and iOS, the type double corresponds to IEEE-754 double precision. A double-precision number is represented in 64 bits, and has a precision of 53 significant bits, roughly like 16 significant decimal digits. 11 bits are used to encode the exponent, which gives an exponent range from -1022 to 1023, inclusive. The header <float.h> defines several useful constants for the double type: DBL_MANT_DIG - The number of binary digits in the significand of a double. DBL_MIN_EXP - One more than the smallest exponent available in the double type. DBL_MAX_EXP - One more than the exponent available in the double type. DBL_DIG - the precision in decimal digits of a double. A decimal value with this many digits, stored as a double, always yields the same value up to this many digits when converted back to decimal notation. DBL_MIN_10_EXP - the smallest n such that 10**n is a non-zero normal number as a double. DBL_MAX_10_EXP - the largest n such that 10**n is finite as a double. DBL_MIN - the smallest positive normal double. DBL_MAX - the largest finite double. DBL_EPSILON - the difference between 1.0 and the smallest double bigger than 1.0. On Intel macs, the type long double corresponds to IEEE-754 double extended precision. A double extended number is represented in 80 bits, and has a precision of 64 significant bits, roughly like 19 significant decimal digits. 15 bits are used to encode the exponent, which gives an exponent range from -16383 to 16384, inclusive. The header <float.h> defines several useful constants for the long double type: LDBL_MANT_DIG - The number of binary digits in the significand of a long double. LDBL_MIN_EXP - One more than the smallest exponent available in the long double type. LDBL_MAX_EXP - One more than the exponent available in the long double type. LDBL_DIG - the precision in decimal digits of a long double. A decimal value with this many digits, stored as a long double, always yields the same value up to this many digits when converted back to decimal notation. LDBL_MIN_10_EXP - the smallest n such that 10**n is a non-zero normal number as a long double. LDBL_MAX_10_EXP - the largest n such that 10**n is finite as a long double. LDBL_MIN - the smallest positive normal long double. LDBL_MAX - the largest finite long double. LDBL_EPSILON - the difference between 1.0 and the smallest long double bigger than 1.0. On ARM iOS devices, the type long double corresponds to IEEE-754 double precision. Thus, the values of the LDBL_* macros are identical to those of the corresponding DBL_* macros. SEE ALSO
math(3), complex(3) STANDARDS
Floating-point arithmetic conforms to the ISO/IEC 9899:2011 standard. BSD
March 28, 2007 BSD
All times are GMT -4. The time now is 07:03 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy