Jump to content
Main menu
Main menu
move to sidebar
hide
Navigation
Main page
Recent changes
Random page
Help about MediaWiki
Special pages
Niidae Wiki
Search
Search
Appearance
Create account
Log in
Personal tools
Create account
Log in
Pages for logged out editors
learn more
Contributions
Talk
Editing
Decimal separator
(section)
Page
Discussion
English
Read
Edit
View history
Tools
Tools
move to sidebar
hide
Actions
Read
Edit
View history
General
What links here
Related changes
Page information
Appearance
move to sidebar
hide
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
===Data vis-Γ -vis mask=== Digit group separators can occur either as part of the data or as a mask through which the data is displayed. This is an example of the [[separation of presentation and content]], making it possible to display numbers in spaced groups while not inserting any [[whitespace character]]s into the string of digits that make up those numbers. In many computing contexts, it is preferred to omit the digit group separators from the data and instead overlay them as a mask (an [[input mask]] or an output mask). Common examples include [[spreadsheet]]s and [[database]]s, in which currency values are entered without such marks but are displayed with them inserted. Similarly, phone numbers can have hyphens, spaces or parentheses as a mask rather than as data. In [[web content]], digit grouping can be done with [[CSS]]. This is useful because the number can be copied and pasted elsewhere (such as into a calculator) and parsed by the computer as-is (i.e., without the user manually purging the extraneous characters). For example: {{block indent |left=1.5 |text={{plainlist}} * {{val|149597870700}} metres is 1 [[astronomical unit]]. * {{gaps|3.14159|26535|89793|23846}} is [[pi|{{pi}}]] rounded to 20 decimal places. * {{gaps|2.71828|18284|59045|23536}} is {{mvar|[[E (mathematical constant)|e]]}} rounded to 20 decimal places. {{endplainlist}}}} In some [[programming language]]s, it is possible to group the digits in the program's [[source code]] to make it easier to read {{xref|(see: {{slink|Integer literal#Digit separators}})}}. Examples include: [[Ada programming language|Ada]], [[C Sharp (programming language)|C#]] (since {{nobr|version 7.0}}),<ref>{{cite report |title=New Features in C# 77.0 |section=Literal improvements |date=9 March 2017 |publisher=Microsoft |type=blog |section-url=https://devblogs.microsoft.com/dotnet/new-features-in-c-7-0/#literal-improvements |access-date=5 May 2022}}</ref> [[D (programming language)|D]], [[Go (programming language)|Go]] (since {{nobr|version 1.13}}), [[Haskell (programming language)|Haskell]] (from GHC {{nobr|version 8.6.1}}), [[Java (programming language)|Java]], [[JavaScript]] (since [[ECMAScript version history#12th Edition β ECMAScript 2021|ES2021]]), [[Kotlin (programming language)|Kotlin]],<ref>{{cite web |title=Basic types |website=Kotlin Language |url=https://kotlinlang.org/docs/basic-types.html#literal-constants:~:text=You%20can%20use%20underscores%20to%20make%20number%20constants%20more%20readable}}</ref> [[OCaml]], [[Perl]], [[Python (programming language)|Python]] (since {{nobr|version 3.6}}), [[PHP]] (since {{nobr|version 7.4}}),<ref>{{cite web |series=PHP: New Features |title=Numeric literal separator |publisher=The PHP Group |url=https://www.php.net/manual/en/migration74.new-features.php#migration74.new-features.core.numeric-literal-separator |access-date=2020-07-16}}</ref> [[Ruby (programming language)|Ruby]], [[Rust (programming language)|Rust]] and [[Zig (programming language)|Zig]]. Java, JavaScript, [[Swift (programming language)|Swift]], [[Julia (programming language)|Julia]] and free-form [[Fortran 90]] use the [[underscore]] ({{code|_}}) character for this purpose. As such, these languages would allow the number seven hundred million to be entered as "700_000_000". On the other hand, fixed-form Fortran ignores whitespace in all contexts, so "{{nobr|700 000 000}}" would be allowed. In [[C++14]], [[Rebol]] and [[Red (programming language)|Red]], the use of an [[apostrophe]] for digit grouping is allowed. Thus, "700'000'000" would be allowed in those languages. The code shown below, written in Kotlin, illustrates the use of separators to increase readability: <syntaxhighlight lang="kotlin" line="1"> val exampleNumber = 12_000_000 // twelve million </syntaxhighlight>
Summary:
Please note that all contributions to Niidae Wiki may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
Encyclopedia:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Search
Search
Editing
Decimal separator
(section)
Add topic