Store...
Moderator: Public Forum Moderators
-
Topic author - Chat Moderator
- Posts: 216
- Joined: Mon Feb 18, 2008 7:36 pm
- Location: Ohio
- Contact:
Store...
I don't know if its not so much a bug as it is a pain in the bum, but whenever entering commas into the price of one's store, it causes the item to be placed in the store at minimum price. Not really a problem as of now, but when we get bigger... I could see it being a pain.
-Coda
Re: Store...
yea thats a strange one R2.. Im not one to normally use commas in my prices but did try it and that would be a pain one day...
Re: Store...
Just a note on this one....
Different countries use different punctuation within currency amounts (prices). Some use commas, some use decimal points. Considering this, I suspect we will probably continue to not use commas to separate values of thousands.
However, perhaps we should reject values with thousands-separators (or ignore them and take only the numerics) to eliminate confusion. This brings up the issue of having to code further validation for that field so it may not be something that happens right away, if at all.
Different countries use different punctuation within currency amounts (prices). Some use commas, some use decimal points. Considering this, I suspect we will probably continue to not use commas to separate values of thousands.
However, perhaps we should reject values with thousands-separators (or ignore them and take only the numerics) to eliminate confusion. This brings up the issue of having to code further validation for that field so it may not be something that happens right away, if at all.
-
Topic author - Chat Moderator
- Posts: 216
- Joined: Mon Feb 18, 2008 7:36 pm
- Location: Ohio
- Contact:
-
- Developer
- Posts: 3396
- Joined: Wed Jun 20, 2007 12:41 am
- Location: Melbourne, Australia
- Contact:
Re: Store...
It's always a good idea to have the option "Auto-Activate on Add New Item" disabled to protect you against exactly that kind of thing.
-
Topic author - Chat Moderator
- Posts: 216
- Joined: Mon Feb 18, 2008 7:36 pm
- Location: Ohio
- Contact:
Re: Store...
It doesn't just happen in the store, when I'm trying to withdraw from stash, it takes the numbers before the comma, and that's all. I was copying and pasting a number that was displayed on the page - with commas - and it didn't take it properly (I selected 34,987 and pasted it in the box, when I had 1,234,987 as displayed in stash). Whether you want the system to work without or with commas, it ought to jive with how the game displays it, so it seems to me.
Perhaps, instead of just taking the numbers before the comma as the total amount, it could generate an error, like it does for other incorrect numbers (too large, etc.) if it encounters a comma. Would it be feasible to have the commas parsed out or something? I know, it's really just a minor annoyance, but it does happen.
Perhaps, instead of just taking the numbers before the comma as the total amount, it could generate an error, like it does for other incorrect numbers (too large, etc.) if it encounters a comma. Would it be feasible to have the commas parsed out or something? I know, it's really just a minor annoyance, but it does happen.
-
- Developer
- Posts: 3396
- Joined: Wed Jun 20, 2007 12:41 am
- Location: Melbourne, Australia
- Contact:
Re: Store...
If only PHP understood that 1,234,567 was the same thing as 1234567, we'd be sweet, but it doesn't do that natively. PHP things a number with comma-separators is a string value, not a number, so I need to write a function to strip the commas out.
It's on the to-do list.
It's on the to-do list.
-
- Developer
- Posts: 3396
- Joined: Wed Jun 20, 2007 12:41 am
- Location: Melbourne, Australia
- Contact:
Re: Store...
Ok, so I just wrote the function (all 4 lines of it). Now I just have to go through ALL 700,000 or so lines of code to find everywhere that a number gets posted by a form and make it use the function. That might take a while
Re: Store...
Looks like I spoke to soon.Grokly wrote:... However, perhaps we should reject values with thousands-separators (or ignore them and take only the numerics) to eliminate confusion. This brings up the issue of having to code further validation for that field so it may not be something that happens right away, if at all.
See what you people do? There's more content not being created.
-
- Developer
- Posts: 3396
- Joined: Wed Jun 20, 2007 12:41 am
- Location: Melbourne, Australia
- Contact:
Re: Store...
Heh, it's not gonna happen tomorrow that's for sure. There's... something else I'm gonna be working on then if I hope to have it out by intermission tomorrow. And if I don't, it's kinda pointless doing at all.
At some point I WILL add the validation code in wherever it's needed. Just... not right now.
At some point I WILL add the validation code in wherever it's needed. Just... not right now.
-
Topic author - Chat Moderator
- Posts: 216
- Joined: Mon Feb 18, 2008 7:36 pm
- Location: Ohio
- Contact:
Re: Store...
I love the inconspicuous "something else" mentioned here. Whatever could that be!? Hehe But I appreciate you taking the time to fix that little quirk. And good luck with your "something else." Im stoked to see it!
-Coda
-
- Developer
- Posts: 3396
- Joined: Wed Jun 20, 2007 12:41 am
- Location: Melbourne, Australia
- Contact:
Re: Store...
Just out of interest, I've discovered that PHP's "round" function rounds 1,234 down to 1 because, regardless of local convention, it treats both '.' and ',' the same. Which is going to make things a fraction harder than I'd like.
And you don't want to KNOW what it does to a number like "1,234,567.89"
And you don't want to KNOW what it does to a number like "1,234,567.89"
-
Topic author - Chat Moderator
- Posts: 216
- Joined: Mon Feb 18, 2008 7:36 pm
- Location: Ohio
- Contact:
-
- Developer
- Posts: 3396
- Joined: Wed Jun 20, 2007 12:41 am
- Location: Melbourne, Australia
- Contact:
Re: Store...
I'd tell you, but the universe would probably implode.
Re: Store...
It would convert it into 1,234,567,89. Or over one billion.
-
- Forum Addict
- Posts: 285
- Joined: Tue Jan 06, 2009 10:10 pm
- Location: Brackney, PA
- Contact:
Re: Store...
unless it only considers them interchangeable within a like group, all periods or all commas. mixing and matching is best left to Maxis games and out of coding, methinks.
-jB
-jB
-
- Developer
- Posts: 3396
- Joined: Wed Jun 20, 2007 12:41 am
- Location: Melbourne, Australia
- Contact:
Re: Store...
Actually, no. PHP's inbuild "round", "floor" and "ceil" functions consider both commas and periods to be separators, so all three round 1,234,567.89 to....heliosa10 wrote:It would convert it into 1,234,567,89. Or over one billion.
1
No, really, it just discards everything after the first separator. Crap, huh?
To do this properly, then, extra code is needed to first strip out the thousand separators and THEN round the number to an integer, ie. "1,234,567.89" -> "1234567.89" -> "1234568" (or "1234567" if we're flooring the final result).
That's great, provided that commas are thousand separators and periods decimal points. If it's the other way around for whoever enters the values, results will be VERY different.
Leave it with me.
-
- Developer
- Posts: 3396
- Joined: Wed Jun 20, 2007 12:41 am
- Location: Melbourne, Australia
- Contact:
Re: Store...
Ackkk, apparently there's more inconsistency in these separators than I originally thought. For example, the number 1234567.89, formatted correctly would be:
Australia/UK/US: 1,234,567.89
France: 1 234 567,89
Germany: 1.234.567,89
So what IS consistent? Well, in all cases, the final separator is the decimal separator, so it should be a matter of finding out what this character is, splitting the string at that point, removing all non-numeric characters from the string on the left, joining it all back together in the local format, then rounding it up or down as required.
Of course, that assumes that, in some countries, thousand separators aren't also used AFTER the decimal point (eg. 1.234.567,891.23...
Alternatively, I could just strip out everything that's not a number, since the game only accepts integers, not decimals. That would mean that "1,234,567.89", "1 234 567,89" and "1.234.567,89" would all just end up as "123456789".
See what happens when I start thinking people are actually interested in all this geekiness? I start telling you about it
Australia/UK/US: 1,234,567.89
France: 1 234 567,89
Germany: 1.234.567,89
So what IS consistent? Well, in all cases, the final separator is the decimal separator, so it should be a matter of finding out what this character is, splitting the string at that point, removing all non-numeric characters from the string on the left, joining it all back together in the local format, then rounding it up or down as required.
Of course, that assumes that, in some countries, thousand separators aren't also used AFTER the decimal point (eg. 1.234.567,891.23...
Alternatively, I could just strip out everything that's not a number, since the game only accepts integers, not decimals. That would mean that "1,234,567.89", "1 234 567,89" and "1.234.567,89" would all just end up as "123456789".
See what happens when I start thinking people are actually interested in all this geekiness? I start telling you about it
-
- Developer
- Posts: 3396
- Joined: Wed Jun 20, 2007 12:41 am
- Location: Melbourne, Australia
- Contact:
Re: Store...
After realising yet another complication with trying to identify thousand and decimal separators based on input, I've decided that the function will treat commas as thousand separators and periods as decimal separators and that's as far as it's going to go. When I finally get around to doing it.
-
- Forum Addict
- Posts: 285
- Joined: Tue Jan 06, 2009 10:10 pm
- Location: Brackney, PA
- Contact:
Re: Store...
/me holds up some pom-poms because there's no way he gets all this math this early in his day.
-jB
-jB
-
- Developer
- Posts: 3396
- Joined: Wed Jun 20, 2007 12:41 am
- Location: Melbourne, Australia
- Contact:
Re: Store...
OK, SOME pages will now let you input comma-separated values. Some won't. Oh, and I found an infinite-moolah bug and fixed it so I guess I get a bugzapper.
-
Topic author - Chat Moderator
- Posts: 216
- Joined: Mon Feb 18, 2008 7:36 pm
- Location: Ohio
- Contact: