Sponsored Content
Top Forums Shell Programming and Scripting Printf question: getting padded zero in decimal plus floating point together. Post 302807485 by MadeInGermany on Tuesday 14th of May 2013 06:44:20 PM
Old 05-14-2013
For this simple example you don't need awk
Code:
$ printf "%06.2f\n" 20.03
020.03

These 2 Users Gave Thanks to MadeInGermany For This Post:
 

10 More Discussions You Might Find Interesting

1. Programming

floating point problem

Hi all! Hi all! I am working with a problem to find the smallest floating point number that can be represented. I am going in a loop ,stating with an initial value of 1.0 and then diving it by 10 each time thru the loop. So the first time I am getting o.1 which I wanted.But from the next... (4 Replies)
Discussion started by: vijlak
4 Replies

2. Programming

Floating point error in C

Hi, see the simple code below double i; i=8080.9940; printf(" val :%.30f\n",i); output i m getting is val :8080.993999999999700000000000000 when i m expecting val :8080.9940 what happens?how can i avoid it? thanks... (2 Replies)
Discussion started by: Hara
2 Replies

3. Linux

Floating point exception !!!

Hi, I have linux fedora 4 ver., 2.6 kernal. And qmail & mysql & samba servers are already configured on this server. When I try to install any package like squidguard ,dansguardian,webmin,rsnapshots with command rpm -ivh . It is giving error as “Floating point exception" Snap View is... (3 Replies)
Discussion started by: ssk01
3 Replies

4. Programming

Floating point Emulator

what is floating point emulator(FPE)? where and why it is used? (1 Reply)
Discussion started by: pgmfourms
1 Replies

5. Shell Programming and Scripting

how to compare 2 floating point no.

Hi, Could any one tell me how to compare to floating point no. using test command. As -eq option works on only intergers. i=5.4 if then echo "equal" else echo "not equal" fi here output will be equal even though no. are unequal. Thanks, ravi (1 Reply)
Discussion started by: useless79
1 Replies

6. Shell Programming and Scripting

floating point numbers in if

# if > then > echo "1" > else > echo "2" > fi -bash: How can i compare floating point numbers inside statement? (15 Replies)
Discussion started by: proactiveaditya
15 Replies

7. Shell Programming and Scripting

Arithmetic in floating point

is it not possible to simply di aritmetic without using bc or awk i have tried folllowing operatrions but they support only integer types plz suggest me code for floating using values stored in the variables.the ans i get is integer and if i input floating values i get error numeric constant... (6 Replies)
Discussion started by: sumit the cool
6 Replies

8. Shell Programming and Scripting

floating point not recognized by printf in bash

Dear all, I have the following question. Let's say that I have the following script #!/bin/bash value=0.4987865 a=` printf "%6.2f" $value ` b=`echo $value + $value | bc -l` echo $a echo $b exit And the exit is: 0,00 .9975730 Thus, the problem is that the printf order does not... (2 Replies)
Discussion started by: josegr
2 Replies

9. Programming

Floating Point

Anyone help me i cant found the error of floating point if needed, i added the code complete #include <stdio.h> #include <string.h> #include <stdlib.h> #include <ctype.h> typedef struct { int hh; int mm; int ss; char nom; int punt; }cancion; typedef struct... (9 Replies)
Discussion started by: Slasho
9 Replies

10. Shell Programming and Scripting

Printf padded string

Is possible to print padded string in printf? Example echo 1 | awk '{printf("%03d\n", $1)}' 001I want S1 S11 S2 S21to be padded as: S01 S11 S02 S21Thanks! (26 Replies)
Discussion started by: yifangt
26 Replies
nextafterd64(3M)														  nextafterd64(3M)

NAME
nextafterd64(), nextafterd128(), nextafterd32(), nexttowardd64(), nexttowardd128(), nexttowardd32() - next representable decimal floating- point numbers SYNOPSIS
DESCRIPTION
The function computes the next representable number following x in the direction toward y. Thus, if y is less than x, returns the largest representable number less than x. The function returns y if x equals y. The function is equivalent to except that the second parameter has the widest decimal floating-point type, and the function returns y con- verted to the type of the function if x equals y. The result of the function is determined in the type of the function, without loss of range or precision in a floating second argument, whose type may be wider than the type of the function. is a version of it takes arguments and returns a result. is a version of it takes arguments and returns a result. is a version of it takes a first argument and returns a result. is a version of it takes a first argument and returns a result. These math functions are supported for HP-UX 11i Version 3 September 2008 Update and forward. USAGE
To use any of these functions, compile with the option. Make sure your program defines and then includes Link in the math library by specifying or on the linking command line. For more information, see the at the following site: RETURN VALUE
If x equals y, returns y, and returns y converted to the type of x. If x is finite and the correct function value would overflow, these functions return according to the sign of x, and raise the overflow and inexact floating-point exceptions. If the return value is subnormal and x!=y, these functions raise the underflow and inexact floating-point exceptions. If x or y is NaN, these functions return NaN. ERRORS
If x is finite and the correct function value would overflow, these functions set to SEE ALSO
scalbnd64(3M), math(5). STANDARDS CONFORMANCE
These functions conform to ISO/IEC TR 24732, "Extension for the programming language C to support decimal floating-point arithmetic". HP Integrity Server Only nextafterd64(3M)
All times are GMT -4. The time now is 12:38 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy