Question : printf c float
Answered by : beautiful-bison-seugh2hf11nn
printf("%.6f", myFloat);
Source : https://stackoverflow.com/questions/8345581/c-printf-a-float-value | Last Update : Thu, 01 Oct 20
Question : printf in c++
Answered by :
#include <cstdio>
int main(){
char c = 'S';
float x = 7.0, y = 9.0;
double d = 6.548;
int i = 50;
printf("The float division is : %.3f / %.3f = %.3f \n", x,y,x/y);
printf("The double value is : %.4f \n", d);
printf("Setting the width of c : %*c \n",3,c);
printf("The octal equivalent of %d is %o \n",i,i);
printf("The hex equivalent of %d is %x \n",i,i);
return 0;
}
Source : | Last Update : Sat, 29 Oct 22
Question : printf
Answered by : zozo
<?php
$n = 43951789;
$u = -43951789;
$c = 65; // ASCII 65 is 'A'
// notice the double %%, this prints a literal '%' character
printf("%%b = '%b'\n", $n); // binary representation
printf("%%c = '%c'\n", $c); // print the ascii character, same as chr() function
printf("%%d = '%d'\n", $n); // standard integer representation
printf("%%e = '%e'\n", $n); // scientific notation
printf("%%u = '%u'\n", $n); // unsigned integer representation of a positive integer
printf("%%u = '%u'\n", $u); // unsigned integer representation of a negative integer
printf("%%f = '%f'\n", $n); // floating point representation
printf("%%o = '%o'\n", $n); // octal representation
printf("%%s = '%s'\n", $n); // string representation
printf("%%x = '%x'\n", $n); // hexadecimal representation (lower-case)
printf("%%X = '%X'\n", $n); // hexadecimal representation (upper-case)
printf("%%+d = '%+d'\n", $n); // sign specifier on a positive integer
printf("%%+d = '%+d'\n", $u); // sign specifier on a negative integer
?>
Source : https://www.php.net/manual/en/function.printf.php | Last Update : Wed, 23 Feb 22
Question : grepper subscription required
Answered by : code-grepper
{"tags":[{"tag":"p","content":"You have reached your max daily Grepper answers. <a href=\"https://www.grepper.com/subscriptions.php\" target=\"_blank\" rel=\"nofollow\">Upgrade to professional </a>to view more Grepper answer today."},{"tag":"p","content":"<a href=\"https://www.grepper.com/api/view_product.php?hl=1&pid=42\" target=\"_blank\" rel=\"nofollow\">Upgrade To Grepper Professional</a>"}]}
Source : | Last Update : Mon, 27 Mar 23
Question : printf
Answered by : niransha
#cat file.txt
#1.11135 -66.8286 0.382867 24.6386 0.693014 175.409 0.763907 -97.6113
cat file.txt | awk '{printf "%-5s%-10s%8s%10s\n","A",$1,$2,"-1.0"}' ^%-5start from left, keep 5 digit space to right ^%8 start from right, keep 8 digit space to letf
output : 1 1.11135 -66.8286 -1.0
#123451234567890123456781234567890
%s a string of characters
%c character
%d decimal (integer) number (base 10)
%e exponential floating-point number
%f floating-point number
%i integer (base 10)
%% print a percent sign
\% print a percent sign
#advacne version of this, with many new lines,
cat file.txt | awk '{printf "%-5s%-10s%8s%10s\n%-5s%-10s%8s%10s\n","A",$1,$2,"-1.0","B",$3,$4,"-2.0"}' ------------------^repeat
var=0.00
awk '{printf "%4s%7.0f%3s%6s%2s%4.0f%12.3f%8.3f%8.3f%6.2f%7.2f\n", $1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $var}' < a.pdb >> dest.pdb
sort -nk2 clus_vs_pupulation.dat | tac | head -n 20 | awk -v tot=$total '{s++; printf("%-11s%2.2f%1s\n", $1,($2*100/tot),"%" )}'
more https://alvinalexander.com/programming/printf-format-cheat-sheet/
Source : | Last Update : Thu, 18 Aug 22
Question : printf
Answered by : nicolezicos
printf "Hello %s, I'm %s" Sven Olga
#=> "Hello Sven, I'm Olga
printf "1 + 1 = %d" 2
#=> "1 + 1 = 2"
printf "This is how you print a float: %f" 2
#=> "This is how you print a float: 2.000000"
Source : https://devhints.io/bash | Last Update : Thu, 07 Apr 22
Question : printf()
Answered by : mike-horoky
{"tags":[{"tag":"textarea","content":"#include <stdio.h>\n \n int main()\n {\n \n printf(\"Words.\");\n \n return 0;\n }","code_language":"c"}]}
Source : https://opaque-cookie-raincoat.glitch.me/c.html | Last Update : Mon, 20 Mar 23