标签: currency

基本的PHP表单帮助(货币显示)

你们昨天非常有帮助.不过我在这里仍然有点困惑.

我想这样做,以便最右边一列的数字四舍五入到最接近的美元:

http://www.nextadvisor.com/voip_services/voip_calculator.php?monthlybill=50&Submit=Submit

该表的代码如下所示:

我想要$ offer [1,2,3,4,5,6,7] calcsavingsann四舍五入,怎么办呢?

 <table width="100%;" border="0" cellspacing="0" cellpadding="0"class="credit_table2" >

    <tr class="credit_table2_brd">
     <td class="credit_table2_brd_lbl" width="100px;">Services:</td>
<td class="credit_table2_brd_lbl" width="120px;">Our Ratings:</td>
<td class="credit_table2_brd_lbl" width="155px;">Monthly VoIP Bill:</td>
<td class="credit_table2_brd_lbl" width="155px;">Annual Savings:</td>

   </tr>  

   <?php

 $offer1price="24.99";
 $offer2price="20.00";
 $offer3price="21.95";
 $offer4price="23.95";
 $offer5price="19.95";
 $offer6price="23.97";
 $offer7price="24.99";

 $offer1calcsavings= $monthlybill - $offer1price;
 $offer2calcsavings= $monthlybill - $offer2price;
 $offer3calcsavings= $monthlybill - $offer3price;
 $offer4calcsavings= $monthlybill - $offer4price;
 $offer5calcsavings= $monthlybill - $offer5price;
 $offer6calcsavings= $monthlybill - $offer6price;
 $offer7calcsavings= $monthlybill - $offer7price;

 $monthybill="monthlybill";

 $offer1calcsavingsann= $offer1calcsavings * 12;
 $offer2calcsavingsann= $offer2calcsavings * 12;
 $offer3calcsavingsann= $offer3calcsavings …
Run Code Online (Sandbox Code Playgroud)

php forms currency rounding

0
推荐指数
1
解决办法
920
查看次数

如何将格式化字符串保存到字符串变量中?

我正在创建一个C#方法,它应该
1.接受一个字符串
2.将该字符串格式化为Currency(无小数或分数)并返回它

String.Format非常适合格式化,但其格式仅适用于打印或输出值.当我单步执行代码时,我可以清楚地看到实际保存到字符串中的值没有格式化.但我需要它格式化.这就是你需要帮助的地方.

在上面的步骤1中,输入的字符串将属于3种可能格式之一.(下面,我用"指定字符串的开头和结尾."实际上并不是字符串的一部分.)
1."<5000"
2."5000-10000"
3."> 10000"

对于这3个例子,该方法应输出
1."<$ 5,000"
2."$ 5,000 - $ 10,000"
3."> $ 10,000"

基本上,该方法应该添加$和,如果需要(什么String.Format做得好).其余的格式化,比如添加<,>或 - 很容易.我可以制作一个方法来手动执行此操作,但必须有一个更简单的方法!

c# string formatting string.format currency

0
推荐指数
2
解决办法
2239
查看次数

在iOS Xcode中划分

不是非常熟悉Xcode或Objective-C,而是试图学习.希望有人可以帮我解决我遇到的问题.

我有两个字段,一个调用price,一个调用units,我正在尝试将单元格的输入相互分开,然后在按下按钮时使用设备的"国籍"的正确货币显示结果.

到目前为止,我已经掌握了按钮的动作;

- (IBAction)calculate:(id)sender {
    int x = [price.text floatValue];
    int y = [units.text floatValue];

    int calc_result = x / y;

    self.result.text = [NSString stringWithFormat:@"%.2f", calc_result];

}
Run Code Online (Sandbox Code Playgroud)

它将结果输出到标签字段而没有小数余数.

如何让它将小数余数显示为2位小数,并将从设备的"国籍"中找到的货币放在前面.

提前致谢!

math currency objective-c division ios

0
推荐指数
1
解决办法
6433
查看次数

适当的JS货币格式,带逗号和小数

我在这里和其他地方浏览了无数线程超过2天,我无法让它正常工作.

我有一个计算器完全按照我需要的方式工作,但是,我似乎无法完成最后一件事.逗号分隔符由千位带小数.

我有小数位,但不能添加逗号.当我添加逗号时,我可以在计算中断之前获得一个或两个字段,或者值显示为NaN.

这是工作页面:http://codepen.io/anon/pen/Fauzy

它目前使用这个:

function FormatAsMoney(mnt) {
mnt -= 0;
mnt = (Math.round(mnt*100))/100;
return (mnt == Math.floor(mnt)) ? mnt + '.00'
: ( (mnt*10 == Math.floor(mnt*10)) ?
mnt + '0' : mnt);
}
Run Code Online (Sandbox Code Playgroud)

如果我尝试使用这个:

function FormatAsMoney(x)

        {


            var money_value;

            mnt = x.value;

            mnt = mnt.replace(/\,/g,'');

            mnt -= 0;

            mnt = (Math.round(mnt*100))/100;

            money_value = (mnt == Math.floor(mnt)) ? mnt + '.00' : ( (mnt*10 == Math.floor(mnt*10)) ? mnt + '0' : mnt);

            if (isNaN(money_value))
            { 
                money_value ="0.00"; …
Run Code Online (Sandbox Code Playgroud)

javascript currency decimal calculator comma

0
推荐指数
1
解决办法
6817
查看次数

确定字符串是否包含任何货币符号?

如何判断某些字符串是否包含任何货币符号?比如,我需要一个函数,如果一个字符串包含任何货币符号(USD,GBP,RUR等),则返回1,否则返回0

321->0
$32->1
34$->1
Run Code Online (Sandbox Code Playgroud)

有没有办法在python中轻松完成?

谢谢.

python string currency

0
推荐指数
1
解决办法
669
查看次数

Java中的货币精度(不是BigDecimal)

我们知道使用float或double不是需要正确精度的选项,我们知道BigDecimal服务于此目的但我们也知道它比常规基元操作慢大约100倍.

现在,如果速度对我们来说至关重要而我们确实需要精确度,我们该怎么办?

我试图以最慢的单位存储货币的价值,并将其转换存储为1 BTC = 100000000 satoshi,但经过几次实验后明确表示您根本无法长期存储100BTC,超过最大可能值.是的,有一个选择牺牲精确度,如存储microBTC等,但问题是更全球化,我们如何用原语设计这样的东西?

java floating-point precision currency

0
推荐指数
1
解决办法
218
查看次数

C#中的美元金额

我查看了其他一些帖子,但似乎没有任何帮助.所以我想要的是一个代码,用一个美元金额读出当前的余额,前面有一个短语.而不是打印美元符号其打印{0:C}.我使用{0:C}不正确吗?

namespace ConsoleApplication7
{
    class Program
    {
        static void Main(string[] args)
        {
            double TotalAmount;
            TotalAmount = 300.7 + 75.60;
            string YourBalance = "Your account currently contains this much money: {0:C} " + TotalAmount;
            Console.WriteLine(YourBalance);
            Console.ReadLine();
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

c# currency string-formatting

0
推荐指数
1
解决办法
986
查看次数

PHP货币格式在需要时添加小数和逗号

如何使用php 将这个数字247936变成这个$ 2,479.36

我尝试了几个选项,例如:

setlocale(LC_MONETARY, 'en_US');
echo money_format('%i', '247936'); // OUTPUT: USD 247,936.00 
Run Code Online (Sandbox Code Playgroud)

我也尝试过这个

echo number_format(247936, 2);  // echos '247,936.00'
Run Code Online (Sandbox Code Playgroud)

我甚至试过这个,但它没有用

echo number_format(247936, 2,'.', ','); // echos 247,936.00
Run Code Online (Sandbox Code Playgroud)

php currency number-formatting money-format

0
推荐指数
1
解决办法
2175
查看次数

格式化为负数货币,或从Double中删除" - "符号

我有一个Double,可以是正面或负面的,我想用以下方式显示:

对于正值:

+ $ 1.10

对于负值:

- $ 0.50

空白为0值

我试过这样的:

Double surcharge = ...
if(surcharge < 0){
    cell.lblSurcharge.text = "-$" + String(format:"%.02f", surcharge)
}else if(surcharge > 0){
    cell.lblSurcharge.text = "+$" + String(format:"%.02f", surcharge)
}else{
    cell.lblSurcharge.text = nil
}
Run Code Online (Sandbox Code Playgroud)

但对于负值,它会像这样显示:

- $ - 0.50

如何正确格式化,或从Double中删除" - "?

currency number-formatting swift

0
推荐指数
1
解决办法
424
查看次数

用正则表达式替换为十进制小数货币

我需要将输入货币(不带小数位)的格式设置为标准方式(如$XXX,XXX,XXX,XXX)。用户可以输入以下任何内容:

  1. $123
  2. $123,123
  3. $1,123,123
  4. 123,123
  5. 12,123,123
  6. 12312312
  7. 123
  8. $12123123

我已经写了一篇文章Regex,我可以通过该文章找到所需的模式-> ^\$?[0-9]{1,3}(?:(,[0-9]{3})*|([0-9]{3})*)?$但我不明白如何编写替代代码格式化上述示例以进行$XXX,XXX,XXX,XXX...格式化(因为没有固定的组可以选择)。

c# regex formatting currency

0
推荐指数
1
解决办法
44
查看次数