Print Page | Close Window

Commas In IGM Numbers

Printed From: Illyriad
Category: Miscellaneous
Forum Name: Suggestions & Game Enhancements
Forum Description: Got a great idea? A feature you'd like to see? Share it here!
URL: http://forum.illyriad.co.uk/forum_posts.asp?TID=4293
Printed Date: 17 Apr 2022 at 03:02
Software Version: Web Wiz Forums 12.03 - http://www.webwizforums.com


Topic: Commas In IGM Numbers
Posted By: Salararius
Subject: Commas In IGM Numbers
Date Posted: 05 Oct 2012 at 05:26
30 of a total 30 for sale at ???????? at [???|???] in ???????? has been accepted by ???? [???] from ?????????? for a total of 292500.0000Gold.

80000 of a total 754000 for sale at ???????? at [???|???] in ??????? has been accepted by ??????? [???] from ???????? for a total of 80000.0000Gold.

100000 of a total 854000 for sale at ???????? at [???|???] in ??????? has been accepted by ??????? [???] from ?????? for a total of 100000.0000Gold.

It's so easy to put commas in numbers and round the decimals.  There's really no reason why any numbers should be in any communication without commas and rounding.  It should be a common function used when outputting any number.  I'm tired of staring at these emails trying to decipher the numbers.

function addCommas(n, dec)
{
  var rx = /(\d+)(\d{3})/;
  var decimalVal = Math.pow(10, dec);
  var numberStr = String(Math.round(n * decimalVal) / decimalVal);

  numberStr = numberStr.replace(/^\d+/, function(w)
                           {
                             while(rx.test(w))
                               w = w.replace(rx, '$1,$2');
                             return w;
                           });
  if (dec == 0)
    return numberStr;
  if (numberStr.indexOf(".") == -1)
    return numberStr + "." + String(decimalVal).substr(1);
  return numberStr + String(decimalVal).substr(numberStr.length - numberStr.indexOf("."))
}




Replies:
Posted By: hellion19
Date Posted: 05 Oct 2012 at 08:15
Would be a nice addition


Posted By: Albatross
Date Posted: 05 Oct 2012 at 10:32
+1, but do it everywhere...  http://forum.illyriad.co.uk/forum_posts.asp?TID=2805&PID=33742&title=localized-commaformatted-numbers#33742" rel="nofollow - http://forum.illyriad.co.uk/forum_posts.asp?TID=2805&PID=33742&title=localized-commaformatted-numbers#33742

-------------


Posted By: DeathDealer89
Date Posted: 05 Oct 2012 at 17:47
I'll counter with y not just use K anytime something goes above 10k  and M anytime something goes above 10M


Posted By: Faenix
Date Posted: 05 Oct 2012 at 18:13
Originally posted by Salararius Salararius wrote:

function addCommas(n, dec)
{
  var rx = /(\d+)(\d{3})/;
  var decimalVal = Math.pow(10, dec);
  var numberStr = String(Math.round(n * decimalVal) / decimalVal);

  numberStr = numberStr.replace(/^\d+/, function(w)
                           {
                             while(rx.test(w))
                               w = w.replace(rx, '$1,$2');
                             return w;
                           });
  if (dec == 0)
    return numberStr;
  if (numberStr.indexOf(".") == -1)
    return numberStr + "." + String(decimalVal).substr(1);
  return numberStr + String(decimalVal).substr(numberStr.length - numberStr.indexOf("."))
}

You could do that .. Or String.Format("{0:n0}", 1234)


Posted By: Rill
Date Posted: 05 Oct 2012 at 19:23
I think it should be in scientific notation --  1.234 x 10^5


Posted By: dunnoob
Date Posted: 05 Oct 2012 at 23:31
/* REXX */ numeric form engineering; numeric digits 5; X = 1.234E5; say X /* yields 123.4E+3 */
Tongue


Posted By: Albatross
Date Posted: 06 Oct 2012 at 01:47
Originally posted by DeathDealer89 DeathDealer89 wrote:

I'll counter with y not just use K anytime something goes above 10k  and M anytime something goes above 10M
Only if a click or floating hint gives you the exact number; sometimes you need the last few digits, especially if transporting resources that are in demand.

-------------


Posted By: Beardo13
Date Posted: 06 Oct 2012 at 08:17
Originally posted by Rill Rill wrote:

I think it should be in scientific notation --  1.234 x 10^5

/me facepalm


Posted By: Salararius
Date Posted: 07 Oct 2012 at 19:38
Originally posted by Faenix Faenix wrote:

You could do that .. Or String.Format("{0:n0}", 1234)
Um, I think that's C#, which is great if they formatted the IGM in C#.  I also don't think that will give the same format.  It will not format the decimals, only add commas.  Which is fine, but I think four decimal places is too many.



Posted By: Bonaparta
Date Posted: 08 Oct 2012 at 00:18
I would like to see change in the numbers also. Perhaps the numbers could be rounded with some sense. If I sell goods for 100M + something, I would much rather see 113.4M rather than 113400000.0000. If numbers are less than 1M than for example 654.3K would also work...

-------------
http://elgea.illyriad.co.uk/a/p/95216" rel="nofollow">



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.03 - http://www.webwizforums.com
Copyright ©2001-2019 Web Wiz Ltd. - https://www.webwiz.net