标签: currency

Python - 接受的货币计算技术是什么?

请看以下示例:

>>> from decimal import Decimal
>>> nrml_price = Decimal('0.59')
>>> discounted = nrml_price / 3  # Taking 2/3 off the price with a coupon
Decimal('0.1966666666666666666666666667')  # Customers don't have fractions of a penny
>>> (nrml_price / 3).quantize(D('0.00'))  # So I quantize to get 2 decimal places
Decimal('0.20')  # Ca fait combien? Cest vingt cents.
Run Code Online (Sandbox Code Playgroud)

问题是,我现在已经在技术上向客户收取超过预期价格的费用,尽管不到3/10美分,但技术上不正确.

我如何克服这样的问题?我是否将其视为生活中的事实,或者是否有可接受的方式来做这种事情(例如,总是向客户收取最近的便士)?

python concurrency currency

1
推荐指数
2
解决办法
1830
查看次数

美元到便士

我在使用正则表达式时遇到了一些问题我正试图花钱$ 28.84并将其作为便士存入我的数据库.现在我正在使用它

$amount="$28.84";
$amount_number= ereg_replace("[(^0-9)(.)(0-9){2}]", "", $amount ); //return a decimal
$store_amount = $amount_number*100; //get number of pennies 
Run Code Online (Sandbox Code Playgroud)

我也试图删除","""和任何不是十进制数字的数字.

php regex currency decimal

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

带有CurrencyFormat和PropertyChanged触发器的TextBox不接受文本权限

TextBox在一个WPF窗口中绑定了一个类型窗口的依赖属性double(见下文).每当用户键入TextBox

  1. TextBox是空的,或
  2. 所有文字都被选中,

键入的文本被错误地接受.例如:如果我在这些场景中输入'5',结果文本为"$ 5.00",但插入符号位于'$'之后的'5'之前.如果我尝试键入"52.1",我会收到"$ 2.15.00".

<Window x:Class="WPF.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="MainWindow" Height="154" Width="240" Name="ThisWindow"
        Background="{StaticResource {x:Static SystemColors.AppWorkspaceBrushKey}}">
    <Grid>
        <TextBox Text="{Binding ElementName=ThisWindow,
                                Path=Amount,
                                StringFormat={}{0:c},
                                UpdateSourceTrigger=PropertyChanged}"
                 VerticalAlignment="Center"
                 HorizontalAlignment="Center"
                 MinWidth="100" />
    </Grid>
</Window>
Run Code Online (Sandbox Code Playgroud)

如果我删除UpdateSourceTrigger属性,它会正确键入,但不保持货币格式.

有任何想法吗?

wpf binding textbox currency string-formatting

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

货币的字符串格式(使用大括号格式化的负值)

当我们转换String.Format("{0:C}", 126.45)它返回$ 126.45

但如果我们转换 String.Format("{0:C}", -126.45)它返回($ 126.45)

为什么负转换返回括号?如果我们不想要这个括号怎么办?

string.format currency

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

php货币

我需要知道如何服用

10.25并将其转为1025

基本上它需要从任何数字中移除句号,例如1500.25它应该是150025

php numbers currency

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

NSString:验证它是美国货币格式

有没有快速的方法来验证NSString是否格式化为美国货币?

所以我要确认的是字符0是$,以下字符是数字,除了string.length-3,它可以是小数(显示更改是可选的).

所以这通过1000美元,这通过1000美元,但这将失败1000美元.

谢谢

currency nsstring ios

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

在使用dompdf的pdf的INR货币符号

我正在使用dompdf来创建一个pdf.当我传递&#8377;给pdf它转换成?

如何使用dompdf在pdf中显示印度货币符号?

php currency dompdf

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

如何在rails中按国家/地区代码获取ISO货币代码?

在我的Rails应用程序我想用country-code,currency-code,ISO locale code从API获取一些数据.当用户从任何地方访问我的网站时,如何动态获取此信息?

我已经使用了地理编码器宝石,所以request.location我将得到位置的信息并使用我可以得到的这个宝石country-code.现在我没有得到如何获得剩余的信息,如currency-code&ISO locale code?? 有谁可以帮助我或指导我?

我看过这个钱宝石,但不确定它会提供给我所有这些信息.

提前致谢 :)

ruby locale currency ruby-on-rails country-codes

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

谷歌货币转换器

我在过去几年里使用过这段代码,但google似乎已经改变了一些链接.出于某种原因,我收到此错误消息:

"输入字符串的格式不正确."

在以下行中:

decimal rate = System.Convert.ToDecimal(match.Groups[1].Value);
Run Code Online (Sandbox Code Playgroud)

我的代码:

try
{
    WebClient web = new WebClient();
    string url = string.Format("https://www.google.com/finance/converter?a={2}&from={0}&to={1}", fromCurrency.ToUpper(), toCurrency.ToUpper(), amount);

    string response = web.DownloadString(url);

    Regex regex = new Regex("rhs: \\\"(\\d*.\\d*)");
    Match match = regex.Match(response);
    decimal rate = System.Convert.ToDecimal(match.Groups[1].Value);

    return rate;
}
catch
{
    return 0;
}
Run Code Online (Sandbox Code Playgroud)

c# regex currency decimal converter

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

转换货币$ 232,680.00到小数

什么是获得十进制值的最佳方法$232,680.00是否可以没有正则表达式.

这也行不通 -

decimal.TryParse(Response.assess_market_value, NumberStyles.Currency, CultureInfo.InvariantCulture, out marketTotalValue);
Run Code Online (Sandbox Code Playgroud)

c# currency decimal

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