Comma Enabled Calculating

Summary: Resources for using numbers with comma as decimal separator for calculating
Version: 2026-02
Prerequisites:
Status:
Maintainer: HansB
License: (Apache 2.0|BSD-3-clause|BSD-2-clause|GPL|LGPL|MIT|MPL-2.0|CDDL-1.0|EPL-1.0) - OpenSourceLicenses Cookbook:Cookbook Licenses
Users: (view / edit)

Questions answered by this recipe

I am used to calculate writing numbers with a comma ,, how can I use such format for number input required for calculations?

Description

This is a resource page for using numbers with comma as decimal separator for calculating. Here you can find tips and links to other recipes and resources about comma enabled calculating.

Introduction

Brief historic perspective

Using a comma as a symbol for separating the integer part from the fraction part of a number is used in many countries all over the world, and in the larger part of Europe. The origins of this go back to the rise of Arabic numerals and the Arabic comma as decimal separator, and their introduction into medieval Europe to surpass the Roman numerals in use. The tradition of using the comma as the main symbol for this purpose has been ongoing. In modern times through the introduction of machine-based computing and the globalisation of financial systems the US American way of using a dot as decimal separator has forced its use on computers for calculations all over the globe, which is at odds with the traditional way calculating is taught in schools and practised in many branches of society.
Read more on Wikipedia: The Decimal Separator

The challenge for computing

To enable the use of commas in numbers for computer-based calculations needs special resources and attention. PmWiki offers many tools to help calculating, not least through user input in forms. But much of this is based on the use of the dot as decimal separator. PHP scripting has a limitation here as well. It mostly requires the dot use in numbers, unless one only uses integers. The PHP function floatval() messes up a number input if it has a comma as decimal separator. For example '123,45', it will output '123', and '2.000,75' will give '2'! The PHP function number_format() should handle changes, but it requires a float number input, not a string! So to use comma-enabled number strings as input one needs special string translation to float numbers, which PHP can handle correctly, and then have results translated back to the comma-separator format.

Resources

...work in progress!...

  • Comma Enabled Markup Expressions - Markup Expressions which allow input of string values which use a comma as decimal separator.
  • FoxCSV - Display csv tables automatically or via templates; filtering, sorting, editing csv data. - FoxCSV lets you set the decimal separator to either comma or dot, which will be used in sums it can create for column values. Thousands separator and how many digits should be shown for the fractal part can also be set.

Usage

Notes

To do / some day / maybe

If you have future plans or wishes for this recipe.

Change log / Release notes

If the recipe has multiple releases, then release notes can be placed here. Note that it's often easier for people to work with "release dates" instead of "version numbers".

See also

Contributors

Comments

See discussion at CommaEnabledCalculating-Talk

User notes : If you use, used or reviewed this recipe, you can add your name. These statistics appear in the Cookbook listings and will help newcomers browsing through the wiki.