3628 点8oophp保留两位小数数怎么保留

503 Service Unavailable
No server is available to handle this request.> 问题详情
中国某服装进出口公司向美国出口价值100万美元的服装,结汇日中国银行公布的外汇牌价为1美元=8.
悬赏:0&答案豆
提问人:匿名网友
发布时间:
中国某服装进出口公司向美国出口价值100万美元的服装,结汇日中国银行公布的外汇牌价为1美元=8.9人民币元,问该公司结汇后可获得多少人民币元?为什么?
网友回答(共0条)
我有更好的答案
相关考试课程
请先输入下方的验证码查看最佳答案
图形验证:
验证码提交中……求一php自定义函数 用来规范价格(小数点后保留两位)_百度知道
求一php自定义函数 用来规范价格(小数点后保留两位)
很简单$money=22;$formatted = sprintf(&%01.2f&, $money);echo $
//输出20.00下面给你这个函数的说明及用法:(phpManual上的,是英文的)上一页
CLXI. String 字符串处理函数 下一页 --------------------------------------------------------------------------------sprintf(PHP 4, PHP 5)sprintf — Return a formatted string说明string sprintf ( string $format [, mixed $args [, mixed $...]] )Returns a string produced according to the formatting string format. 参数formatThe format string is composed of zero or more directives: ordinary characters (excluding %) that are copied directly to the result, and conversion specifications, each of which results in fetching its own parameter. This applies to both sprintf() and printf(). Each conversion specification consists of a percent sign (%), followed by one or more of these elements, in order: An optional sign specifier that forces a sign (- or +) to be used on a number. By default, only the - sign is used on a number if it's negative. This specifier forces positive numbers to have the + sign attached as well, and was added in PHP 4.3.0. An optional padding specifier that says what character will be used for padding the results to the right string size. This may be a space character or a 0 (zero character). The default is to pad with spaces. An alternate padding character can be specified by prefixing it with a single quote ('). See the examples below. An optional alignment specifier that says if the result should be left-justified or right-justified. The default is right- a - character here will make it left-justified. An optional number, a width specifier that says how many characters (minimum) this conversion should result in. An optional precision specifier that says how many decimal digits should be displayed for floating-point numbers. When using this specifier on a string, it acts as a cutoff point, setting a maximum character limit to the string. A type specifier that says what type the argument data should be treated as. Possible types: % - a literal percent character. No argument is required.
b - the argument is treated as an integer, and presented as a binary number.
c - the argument is treated as an integer, and presented as the character with that ASCII value.
d - the argument is treated as an integer, and presented as a (signed) decimal number.
e - the argument is treated as scientific notation (e.g. 1.2e+2). The precision specifier stands for the number of digits after the decimal point since PHP 5.2.1. In earlier versions, it was taken as number of significant digits (one less).
u - the argument is treated as an integer, and presented as an unsigned decimal number.
f - the argument is treated as a float, and presented as a floating-point number (locale aware).
F - the argument is treated as a float, and presented as a floating-point number (non-locale aware). Available since PHP 4.3.10 and PHP 5.0.3.
o - the argument is treated as an integer, and presented as an octal number.
s - the argument is treated as and presented as a string.
x - the argument is treated as an integer and presented as a hexadecimal number (with lowercase letters).
X - the argument is treated as an integer and presented as a hexadecimal number (with uppercase letters).
The format string supports argument numbering/swapping. Here is an example: 例 2326. Argument swapping&?php$format = 'There are %d monkeys in the %s';printf($format, $num, $location);?& This might output, &There are 5 monkeys in the tree&. But imagine we are creating a format string in a separate file, commonly because we would like to internationalize it and we rewrite it as: 例 2327. Argument swapping&?php$format = 'The %s contains %d monkeys';printf($format, $num, $location);?& We now have a problem. The order of the placeholders in the format string does not match the order of the arguments in the code. We would like to leave the code as is and simply indicate in the format string which arguments the placeholders refer to. We would write the format string like this instead: 例 2328. Argument swapping&?php$format = 'The %2$s contains %1$d monkeys';printf($format, $num, $location);?& An added benefit here is that you can repeat the placeholders without adding more arguments in the code. For example: 例 2329. Argument swapping&?php$format = 'The %2$s contains %1$d monkeys.
That\'s a nice %2$s full of %1$d monkeys.';printf($format, $num, $location);?& args...返回值Returns a string produced according to the formatting string format. 更新日志版本 说明 4.0.6 Support for argument numbering/swapping was added
范例例 2330. printf(): various examples&?php$n =
;$u = -;$c = 65; // ASCII 65 is 'A'// notice the double %%, this prints a literal '%' characterprintf(&%%b = '%b'\n&, $n); // binary representationprintf(&%%c = '%c'\n&, $c); // print the ascii character, same as chr() functionprintf(&%%d = '%d'\n&, $n); // standard integer representationprintf(&%%e = '%e'\n&, $n); // scientific notationprintf(&%%u = '%u'\n&, $n); // unsigned integer representation of a positive integerprintf(&%%u = '%u'\n&, $u); // unsigned integer representation of a negative integerprintf(&%%f = '%f'\n&, $n); // floating point representationprintf(&%%o = '%o'\n&, $n); // octal representationprintf(&%%s = '%s'\n&, $n); // string representationprintf(&%%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 integerprintf(&%%+d = '%+d'\n&, $u); // sign specifier on a negative integer?& 上例将输出:%b = '01'%c = 'A'%d = ';%e = '4.3;%u = ';%u = ''%f = '000'%o = ''%s = ';%x = '29ea6ad'%X = '29EA6AD'%+d = '+;%+d = '-;例 2331. printf(): string specifiers&?php$s = 'monkey';$t = 'many monkeys';printf(&[%s]\n&,
$s); // standard string outputprintf(&[%10s]\n&,
$s); // right-justification with spacesprintf(&[%-10s]\n&,
$s); // left-justification with spacesprintf(&[%010s]\n&,
$s); // zero-padding works on strings tooprintf(&[%'#10s]\n&,
$s); // use the custom padding character '#'printf(&[%10.10s]\n&, $t); // left-justification but with a cutoff of 10 characters?& 上例将输出:[monkey][
monkey][monkey
][0000monkey][####monkey][many monke]例 2332. sprintf(): zero-padded integers&?php$isodate = sprintf(&%04d-%02d-%02d&, $year, $month, $day);?& 例 2333. sprintf(): formatting currency&?php$money1 = 68.75;$money2 = 54.35;$money = $money1 + $money2;// echo $money will output &123.1&;$formatted = sprintf(&%01.2f&, $money);// echo $formatted will output &123.10&?& 例 2334. sprintf(): scientific notation&?php$number = ;echo sprintf(&%.3e&, $number); // outputs 3.625e+8?& 参见printf() sscanf() fscanf() vsprintf() number_format() --------------------------------------------------------------------------------上一页
上一级 下一页 soundex
起始页 sscanf
其他类似问题
为您推荐:
小数点的相关知识
等待您来回答
下载知道APP
随时随地咨询
出门在外也不愁1o千克一4千克8oo克用小数计算_百度知道
1o千克一4千克8oo克用小数计算
1o千克一4千克8oo克用小数计算
4千克800克=4.8千克10千克-4千克800克=10-4.8=5.2千克
来自团队:
其他类似问题
为您推荐:
其他1条回答
1o千克一4千克8oo克用小数计算=10千克-4.8千克=5.2千克
等待您来回答
下载知道APP
随时随地咨询
出门在外也不愁}

我要回帖

更多关于 excel保留两位小数 的文章

更多推荐

版权声明:文章内容来源于网络,版权归原作者所有,如有侵权请点击这里与我们联系,我们将及时删除。

点击添加站长微信