Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
13 Jun 22 - 14 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
1
Question by just_a_guest · Dec 31, 2021 at 11:55 AM · uitextnumbers

how to remove E+ in long numbers.

So I was experimenting with long numbers and E+ showed up when I displayed it on UI text. How can I remove it?.

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

· Add your reply
  • Sort: 
avatar image
2

Answer by Bunny83 · Dec 31, 2021 at 12:27 PM

Well, by default ToString for floats uses a 7 digit format (I think it's "G7"). If the lenght of the number exceeds 7 characters it switches to scientific notation. This makes sense for two reasons: First of all a float has roughly an accuracy of 7 significant decimal digits. So values larger that that can't really represent the one's column anymore. Over here I posted a table how the precision of floats degrade with the size of the numbers. The other reason is that floating point numbers could grow up to 38 digits (a double up to 308 digits) and for almost all purposes it makes no sense to write out such long numbers.


Anyways, if you really just want to display large numbers with their best decimal expansion, you can always use a different format specifier. For example using .ToString("G30") would display up to 30 digits before switching to scientific / exponential notation. There are also other format specifiers for different purposes like currency. Though the exact format of all of them depends on the used culture setting. Keep in mind that about half the world is using a "comma" , as decimal point while the other half uses the "dot" .. It gets even more complicated when it comes to grouping in different cultures.


C# / .NET specifically has an invariant culture that currently matches more or less the english culture setting but it will never change in the future while the individual cultures of countries can change over time. So it depends on the usecase what you want to use when. If it's for displaying numbers to the user, using the local culture (which is the default) is usually the best because numbers are formatted the way they are used to. However if the number should be serialized / stored or send over to another machine on the world, it's always better to use the invariant culture. Otherwise information generated / stored on one machine could not be read properly on another. Though, as I said, this all depends on the usecase.

Comment
Add comment · Show 2 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Pangamini · Dec 31, 2021 at 12:36 PM 0
Share

Great answer. I am wondering, if OP's referring to the default behavior of built-in components and drawers, would this be affected by modifying windows' region settings? If that's linked to the .net default culture... can this specific property be set somehow in the system?

avatar image Bunny83 Pangamini · Jan 01 at 12:44 AM 0
Share

The .NEt culture system uses the systems culture settings. So yes, if you're on windows it should use the settings that you set in the windows config. Though I don't think there is a specific setting for each of the format strings. Though there are general settings for the decimal point and grouping character. It's quite hidden in Win10 under 3 or 4 layers in the region settings.

I can remember that in the past I manually changed the decimal point from comma (german culture) to a dot because it was just annoying in various places ^^. Since 90 - 95% of what I do is related to program$$anonymous$$g it just made more sense that way.

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

231 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

UI text is scrambled in mobile and don't get fixed until updated 0 Answers

Text shows on Even numbers, then another text shows on Odd numbers. 0 Answers

New UI: change text 2 Answers

UGUI Find tapped character in textfield? 1 Answer

How to attach a canvas to a game object properly? 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges