Why would the swift language designers choose to seperare numbers by underscores instead of a comma [closed] - swift

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 8 years ago.
Improve this question
Numeric literals can contain extra formatting to make them easier to read. Both integers and floats can be padded with extra zeroes and can contain underscores to help with readability. Neither type of formatting affects the underlying value of the literal:
let paddedDouble = 000123.456
let oneMillion = 1_000_000
let justOverOneMillion = 1_000_000.000_000_1

Well for one thing not all locales separate numbers with commas. Moreover, using comma separators could become confusing syntactically; consider the following function call:
foo(123,456)
Is it one literal 123,456, or two distinct arguments 123 and 456?

Reason #1: Commas would be ambiguous – it would be impossible to distinguish the following cases:
var prices: [Double] = [1,234.00, 99.99]
# evaluates to
var prices: [Double] = [1.00, 234.00, 99.99]
However underscores are not ambiguous in this case:
var prices: [Double] = [1_234.00, 99.99]
Reason #2: The underscore is generally used to indicate a discarded value which makes sense in this context (it is essentially a discarded digit).
Reason #3: Swift is inspired by Ruby, which does the same thing.

I am not a Swift language designer (and I'm not sure anyone who is posts on SO in any official capacity, so this might not be the best place for directing questions at them), but I have a couple of guesses:
the comma is an operator in Swift (works about the same as in C)
not everybody uses comma as the thousands separator
you can use underscore to break up any numeric literal in any way that helps it be readable to you, not just as a thousands separator

Related

E PROBLEMS when using Excel [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 1 year ago.
Improve this question
Hi my problem is everytime I use excel and place an E in the cell with numbers it turns it into a mathematical equation.
Example: 6807E02 turns to 6.81E+05. Totally driving me insane. Someone please help me?
This is happening because Excel assumes you are entering a number using a variant of scientific notation called E Notation. When you enter 6807E02, Excel assumes you are talking about the number 680,700 (6807 x 10 ^ 2). Excel has it's own method of formatting scientific notation, which is to always put the decimal to the right of the first digit, and end with the E (the multiple of 10) to the far right. That's why you're seeing 6.81E+05 (the display rounds to two digits after the decimal, but the number is still the same).
If you're intentionally trying to type in the text value "6807E02", you can either set the cell's data type to "Text" (Image below), or you can type the single apostrophe key (') before you start entering the number. If you want the number you typed in, but you don't want Excel to override your number formatting, that's unfortunately beyond my abilities. Excel is pretty stringent with custom formatting when it comes to Scientific Notation. You would probably end up spending far more time trying to force Excel to accept your notation as a custom format than the value doing so would add to your project.
Hope this helps!
Hi this link should help you,
From what I can see the easiest solution would be if you put an apostrophe (') in front of the number excel will treat it as text.
For example '6807E02

Map special characters to URL safe, readable versions [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 8 years ago.
Improve this question
i am looking for a mapping table or Perl module or anything else, which makes it possible to map characters to a URL safe version that is also readable.
I need to build URLs without any special characters. The base words are city names in their native language which means it can contain special characters from that language.
For example, when i have something like the polish city name 'łódź' i need to get a readable version like: 'lodz'
The major browsers show and accept non-ASCII characters in the URL bar even if they need to be encoded during transmission.
For example,
http://.../city/Montr%C3%A9al
will appear as
http://.../city/Montréal
in the browser's URL bar. [Test]
But if you want to convert to a subset of ASCII, you'd start by using Text::Unidecode's unidecode. Then you gotta decide what to do with the characters that must be escaped in URLs.

How does compiler understand Unicode characters so quickly? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I have made a document based program lately.
But what intrigues me that how can a compiler(in my case, objective-c) convert any character into Unicode so fast while these characters are only visual presentations.
I think maybe A~Z and all other common characters can be converted from ASCII to Unicode very easily. What about other special character such as brand icon and copyright icon?
I am solely interested in the internal working of such conversion.
Example:
How do compiler understand what "©" is in a blink of second? Is it by looking up a UNICODE table? But if I have 1000000 "©", does my compiler look them up in the table 1000000 times? That is very time consuming, isn't it?
The compiler doesn't see "©". It sees whatever numerical representation of "©" occurs in the source file it's processing. No lookup is needed, because it's already in the form the compiler uses. (Some conversions might be needed if, for example, the source file is in UTF-8 and the compiler uses UTF-32 internally, but such conversions don't require a full Unicode table.)

How to convert character to unicode? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 years ago.
Improve this question
I have this character.
&#8211
How to convert this character to unicode?
Sorry if it is a silly question.
It's not a silly question, character encoding can be tricky to get your head around. I highly recommend reading The Absolute Minimum Every Software Developer Absolutely, Positively Must Know About Unicode and Character Sets (No Excuses!) (I'm sure you can guess the topic).
Unicode itself isn't an encoding, it's a very long list of characters and code points. What I'm guessing you want to do is display the dash character in some way. Where are you wanting to display or store the data? If it's in a browser, then that representation should work as that's the HTML encoded version. If you want to store it in a database then you'll need to convert that encoded version to a string and then convert that string to whatever encoding the database is using.
Take a look at this source has the encoding in different formats
http://www.fileformat.info/info/unicode/char/2013/index.htm
but each language has its own rules on how to write this in a string/char literal

Looking for special characters in Google [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
Do you know how to look for special characters with google...?
I'm looking at bash code and there's the ## operator. I would like to know what It does but I wasn't able to figure out a way to protect the character (I'm not sure it's even possible).
This is particularly annoying when you're looking for some code patterns, some characters are always ignored.
Update: this answer is no longer applicable as of 2017. See https://blog.google/products/search/improvements-searching-special-characters-programming-languages/
Google strips most punctuation from queries, as described here, so it won't help you with the bash syntax.
It's very easy to search for the string "##" in the bash documentation: Just run "info bash", hit "s", and enter "##" as the search string.
google strips puntuation, imho, because:
it's somewhere used for special search (chars like - to exclude, +to add and 10..20 to specify a range)
to avoid spammers to get email addresses (characters like # or .)
in my experience, it's even impossible to escape special characters.
the only solution I found, by now, is using yahoo http://it.search.yahoo.com/