首页 \ 问答 \ 正确格式化货币到小于Locale指定的小数位(Correctly formatting currencies to more decimal places than the Locale specifies)

正确格式化货币到小于Locale指定的小数位(Correctly formatting currencies to more decimal places than the Locale specifies)

在法国和其他国家/地区,货币符号在货币金额之后,而在其他国家则在之前,加上小数分隔符是逗号而不是点( £0.000,00 € )。

如果我在我的Android设备上使用以下Java代码(来自内存,可能无法编译),我可以获得一个正确格式化的NumberFormat

NumberFormat format = NumberFormat.getCurrencyInstance(Currency.get(Locale.FRANCE));

NumberFormat格式化为正确的小数位数(在上面的示例中为两个)。

我想格式化为金融应用程序的10位小数,同时保持小数点分隔符和“符号侧”正确。

我很乐意构建自己的格式表达式 - 问题是找到特定LocaleCountry 。 有没有办法在运行时从Java / Dalvik VM中找到它,或者我只是需要对其进行硬编码?

硬编码并不是一个真正的问题,因为我只有大约20种货币需要担心,但显然如果它可以派生,那就更容易:)


In France and other countries, the currency symbol is after a monetary amount while in others it is before, plus, the decimal separator is a comma rather than a point (£0.00 vs 0,00 €).

If I use the following Java code (from memory, may not compile) on my Android device, I can get a NumberFormat which formats things correctly:

NumberFormat format = NumberFormat.getCurrencyInstance(Currency.get(Locale.FRANCE));

This NumberFormat formats to the correct number of decimal places (two in the above examples).

I would like to format to 10 decimal places for a financial app, while keeping the decimal separator and 'symbol side' correct.

I can quite happily build my own format expression - the problem is finding out the information for a particular Locale or Country. Is there a way of finding this out at runtime from the Java/Dalvik VMs or am I just going to have to hard code it?

Hard coding it isn't really a problem as I only have about 20 currencies to worry about, but obviously if it can be derived then that is even easier :)


原文:https://stackoverflow.com/questions/5003609
更新时间:2022-12-31 15:12

最满意答案

采样器glUniform1i的参数范围为[0:MAX[ ,而不是[GL_TEXTURE0:GL_TEXTURE0+MAX[

所以将您的代码更改为:

glUniform1i(..., 0);

The parameter for glUniform1i for samplers is in the range [0:MAX[, not [GL_TEXTURE0:GL_TEXTURE0+MAX[.

so change your code to:

glUniform1i(..., 0);

相关问答

更多
  • 纹理采样是通过硬件纹理单元完成的,因此无法进一步优化它。 纹理查找的主要成本在于内存访问,因此您可以考虑使用mipmapping来避免缓存未命中。 Texture sampling is done through hardware texture units, so there is no way to optimize it further. The main cost of texture lookup is in memory access, so you may consider mipmappin ...
  • 在我告诉你如何让你的着色器工作之前,你可以说不应该这样做。 你也应该 制作2个着色器 制作一个使用纹理的着色器和使用顶点颜色的不同着色器。 这就是几乎所有专业游戏引擎都会做的事情。 制作一个将两种颜色相乘并将其设置为白色的着色器 如果你有 gl_FragColor = vertexColor * textureColor; 然后,如果textureColor是1,1,1,1 ,这意味着你乘以1,结果只是vertexColor 。 类似地,如果vertexColor是1,1,1,1那么你将乘以1,因此结果只 ...
  • 由于您链接到描述纹理喷溅的答案,并且其问题提到游戏Oblivion,我可以提供一些额外的洞察力。 使用RGBA混合贴图的基本纹理喷涂仅支持每个地形四边形的四个纹理,但您可以为不同的四边形使用不同的纹理集。 Oblivion将其地形划分为每边32个网格点(192英尺)的正方形(称为“单元格”),每个单元格定义自己的四个地形纹理集。 因此,您不能在一个小区域内拥有大量的纹理多样性,但您可以轻松地在较大区域上改变纹理。 如果您愿意,可以为较小的区域(甚至是单个四边形)定义纹理集,但代价是使用更多内存。 如果您在四 ...
  • 对不起,你不能从GLSL那里访问那种状态。 事实上,在未来的GLSL中,你必须自己发送所有的非形式/属性,即没有automagic gl_ModelViewMatrix,gl_LightPosition,gl_Normal等。 只有基本的东西,如gl_Position和gl_FragColor将可用。 这种空洞的第二个问题,但你总是可以使用#ifdef来启用/禁用你的着色器中的部分,如果你发现比为不同的纹理模式编写单独的着色器更方便。 相关的,请注意,分支通常很慢,所以如果你需要速度,尽量避免分支。 (这很 ...
  • 要根据值a混合两个纹理: float a = ...; vec3 color0 = texture(texture0, pass_textureCoords).rgb; vec3 color1 = texture(texture1, pass_textureCoords).rgb; out_Color.rgb = mix(color0, color1, a); 假设你的unitNormal = (0,1,0)是向上的方向,就像它从代码中看到的那样,那么 float a = clamp(unitNormal ...
  • 采样器glUniform1i的参数范围为[0:MAX[ ,而不是[GL_TEXTURE0:GL_TEXTURE0+MAX[ 。 所以将您的代码更改为: glUniform1i(..., 0); The parameter for glUniform1i for samplers is in the range [0:MAX[, not [GL_TEXTURE0:GL_TEXTURE0+MAX[. so change your code to: glUniform1i(..., 0);
  • 有许多方法可以自动生成纹理坐标,但我不知道有什么简单的方法可以为您提供坐标而不会出现明显的失真或过多的不连续性。 我想说最简单的方法是编写一个小程序,从当前的模型格式转换为更标准的格式。 我在过去做过这个,我发现XNA .x格式很容易转换为。 我认为你尝试的任何其他事情最终都会花费更长的时间,而且比使用3D建模软件包中提供的工具更难。 如果你绝对肯定你不想做转换,那么我的建议是瞄准简单的事情,并接受结果不会很好。 一种简单的方法是球面投影 - 基本上,您可以根据与从模型中心到顶点的矢量对应的“纬度”和“经度 ...
  • 您需要一些库或接口来创建OpenGL上下文 (以及一个显示它的窗口)。 GLUT已经过时,但仍然很受欢迎; 现在很好的选择是GLFW或SDL。 我推荐GLFW。 (顺便说一句,为什么你甚至需要编译GLUT?它是不是有预编译的Windows二进制文件?) 或者您可以使用特定于系统的功能; 在你的情况下 - WinAPI。 但是,这是一个非常繁琐的过程; 与便携式解决方案不同的是,它只用一行或两行代码创建一个窗口,并提供简单的输入处理。 启动并运行GL窗口后, 您可以 从任何教程中 学习纹理 (或其他任何内容) ...
  • 您可以像下面的代码段一样合并几何图形,从而只生成一个网格。 根据您之前的问题,您已经知道如何纹理单个几何体。 var geometry1 = new THREE.ExtrudeGeometry( shape1, extrusionSettings ); var geometry2 = new THREE.ExtrudeGeometry( shape2, extrusionSettings ); geometry1.merge( geometry2 ); . . . var mesh = new THR ...
  • 是的,QOpenGLFrameBufferObject早于QOpenGLTexture,因此它不使用或公开QOpenGLTexture。 它应该被添加,但实际上,QOpenGLFBO应该被重写以支持多个附件。 除此之外,手动使用GL调用有什么问题? GLuint textureId = fbo->texture(); glActiveTexture(GL_TEXTURE4); glBindTexture(GL_TEXTURE_2D, textureId); glActiveTexture(GL_TEXTU ...

相关文章

更多

最新问答

更多
  • 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
  • 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
  • OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
  • 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
  • codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
  • 在计算机拍照在哪里进入
  • 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
  • No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
  • 单页应用程序:页面重新加载(Single Page Application: page reload)
  • 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
  • System.StackOverflow错误(System.StackOverflow error)
  • KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
  • 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
  • android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
  • TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
  • 企业安全培训的各项内容
  • 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
  • C#类名中允许哪些字符?(What characters are allowed in C# class name?)
  • NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
  • 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
  • 将多个行和可变行移动到列(moving multiple and variable rows to columns)
  • 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
  • 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
  • Angular $资源不会改变方法(Angular $resource doesn't change method)
  • 在Angular 5中不是一个函数(is not a function in Angular 5)
  • 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
  • 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
  • 常见的python rpc和cli接口(Common python rpc and cli interface)
  • Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
  • 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)