Comment On Multiplying Strings

It was supposed to be simple. The plan was that Alex would temporarily inherit support an old VB e-commerce website for a week while a colleague was out on vacation. With the web being out there for years and years, Alex assumed that most of the old bugs had been squashed leaving him with a nice and quiet week on his hands. As it turned out, Alex had assumed incorrectly. [expand full text]
« PrevPage 1 | Page 2Next »

Re: Multiplying Strings

2012-12-06 08:04 • by alo
ot*"0.Frist"

Good thing is that even discount percentages like 1000% wouldn't make the final price negative...

Re: Multiplying Strings

2012-12-06 08:06 • by Nobody (unregistered)
Lame


Additional text to avoid spam filter

Re: Multiplying Strings

2012-12-06 08:07 • by ochrist
396558 in reply to 396556
alo:
Am I frist this time?

Yeah, but you didn't get the joke. You should have made a long comment....

Re: Multiplying Strings

2012-12-06 08:10 • by alo
396559 in reply to 396558
The "frist" strategy is to be logged in, writing a comment as fast as you can and the edit it later to something less embarrasing.

Re: Multiplying Strings

2012-12-06 08:13 • by ¯\(°_o)/¯ I DUNNO LOL (unregistered)
TRWTF is that some people shouldn't be allowed near anything that requires 9th grade mathematics skills. This isn't even algebra.

VB? How am I not surprised? (It was either that or PHP.)

Re: Multiplying Strings

2012-12-06 08:16 • by alvatrus (unregistered)
396561 in reply to 396559
Which makes *every* poster of *any* top comment a loser by default.

Re: Multiplying Strings

2012-12-06 08:17 • by Cbuttius
The person who wrote that had the right buzzwords on their CV - they'd played with the right toys.

And they probably had nice personalities as well and came across well at their interviews.

Of course using string conversion is a total WTF. That the code also doesn't work actually gives him grounds to change it, so perhaps better than if it were written correctly.

The code appears to not work because they forget that you need 2 digits to represent the percent so it is giving a discount of 0.5 when it should be 0.05?

Re: Multiplying Strings

2012-12-06 09:07 • by AGray (unregistered)
396565 in reply to 396560
¯\(°_o)/¯ I DUNNO LOL:
TRWTF is that some people shouldn't be allowed near anything that requires 9th grade mathematics skills. This isn't even algebra.

VB? How am I not surprised? (It was either that or PHP.)


I digress...but, why is it most of the more horrendously stupid WTFs are written in VB? I have never really understood it.

Re: Multiplying Strings

2012-12-06 09:10 • by b_russel (unregistered)
I wonder what would have happened if the original programmer would have fixed this bug: Would he have added a few PadLeft and IndexOf calls, and a regular expression or two for good measure? ;-)

Re: Multiplying Strings

2012-12-06 09:15 • by the beholder (unregistered)
396568 in reply to 396562
Cbuttius:
The person who wrote that had the right buzzwords on their CV - they'd played with the right toys.

And they probably had nice personalities as well and came across well at their interviews.

Of course using string conversion is a total WTF. That the code also doesn't work actually gives him grounds to change it, so perhaps better than if it were written correctly.

The code appears to not work because they forget that you need 2 digits to represent the percent so it is giving a discount of 0.5 when it should be 0.05?

Ooookay... that is what is missing. I wasn't sure what was the bug until I read your post.

Yes people, the code is awful, but it at least is written in a way that's supposed to calculate the right amount (except when it fits Cbuttius' example). If you feed it a 10% discount or higher it will perform correctly.

It's the stupider, bug-prone route to the right place.

Re: Multiplying Strings

2012-12-06 09:35 • by Foo Bar (unregistered)
396569 in reply to 396565
AGray:
I digress...but, why is it most of the more horrendously stupid WTFs are written in VB? I have never really understood it.

Possibly because some Peters rise up to their level of incompetence by way of:
use MS Office products -> write a macro or two -> hey, that's Visual Basic -> VB programmer.

Re: Multiplying Strings

2012-12-06 09:41 • by Peter Bouillon (unregistered)
Yes, of course this code is to blame.

* If O.DiscountPercentage is lower than 10, then the calculated discount will off by a factor of 10.

* If O.DiscountPercentage contains a decimal point (e.g. "10.5"), the digits behind it will be lost.

* If O.DiscountPercentage is negative, then "0." & Convert.ToInt32(O.DiscountPercentage) will result in nonsense.

Re: Multiplying Strings

2012-12-06 09:45 • by Peter Bouillon (unregistered)
396571 in reply to 396568
the beholder:

If you feed it a 10% discount or higher it will perform correctly.


It won't work with a 100% discount.

Re: Multiplying Strings

2012-12-06 09:48 • by very punny (unregistered)
[quote] but one thing was for certain - this was going to be a long<!--Get it? Long...Decimal... When was the last time you saw a data type pun?--> week. [\quote]

He was going to need to use a float-ing holiday after this.

Re: Multiplying Strings

2012-12-06 09:50 • by TheSHEEEP (unregistered)
396573 in reply to 396569
Foo Bar:
AGray:
I digress...but, why is it most of the more horrendously stupid WTFs are written in VB? I have never really understood it.

Possibly because some Peters rise up to their level of incompetence by way of:
use MS Office products -> write a macro or two -> hey, that's Visual Basic -> VB programmer.


Also, it is (or was, rather, guess today it is JavaScript) used in many schools for computer science lessons.

Re: Multiplying Strings

2012-12-06 10:20 • by Pokepoke (unregistered)
This sounds like a beginning of a journey... Cant wait for chapter 2 to come!

Re: Multiplying Strings

2012-12-06 10:35 • by RRDY (unregistered)
But dividing by 100 is HARD!

captcha: nobis, as in this person had nobis getting anywhere near a computer.

Re: Multiplying Strings

2012-12-06 10:43 • by Herwig (unregistered)
396577 in reply to 396569
Foo Bar:
AGray:
I digress...but, why is it most of the more horrendously stupid WTFs are written in VB? I have never really understood it.

Possibly because some Peters rise up to their level of incompetence by way of:
use MS Office products -> write a macro or two -> hey, that's Visual Basic -> VB programmer.

...and then they are talking about the "Storage Procedures" they've written in "Virtual Basic" and their other programming skills in in HTML or FTP...

Re: Multiplying Strings

2012-12-06 10:47 • by Valetudo (unregistered)
396578 in reply to 396577
Herwig:
Foo Bar:
AGray:
I digress...but, why is it most of the more horrendously stupid WTFs are written in VB? I have never really understood it.

Possibly because some Peters rise up to their level of incompetence by way of:
use MS Office products -> write a macro or two -> hey, that's Visual Basic -> VB programmer.

...and then they are talking about the "Storage Procedures" they've written in "Virtual Basic" and their other programming skills in in HTML or FTP...


In the final stages, they talk about writing a gui in VB to trace an IP.

Re: Multiplying Strings

2012-12-06 11:00 • by Someone (unregistered)
Just back from the trauma center, no further comments.

Re: Multiplying Strings

2012-12-06 11:06 • by lethalronin27
396582 in reply to 396571
Peter Bouillon:
the beholder:

If you feed it a 10% discount or higher it will perform correctly.


It won't work with a 100% discount.


Or any percentage with a decimal, like 33.33%

Re: Multiplying Strings

2012-12-06 11:39 • by Coyne
396583 in reply to 396576
RRDY:
But dividing by 100 is HARD!

captcha: nobis, as in this person had nobis getting anywhere near a computer.


Inefficient, too.

Had a teacher one time that assigned us to minimize parenthesis in something like this:

 A + ((B * C) * (D * E)) / ((F * G) * H)


My response:

 A + B * C * D * E / F / G / H


Whereupon he objected lamely that division was inefficient...but he gave in when I pointed out that the whole objective of the problem was to get rid of parenthesis.

Re: Multiplying Strings

2012-12-06 11:55 • by Spudley (unregistered)
396584 in reply to 396572
[quote user="very punny"][quote] but one thing was for certain - this was going to be a long<!--Get it? Long...Decimal... When was the last time you saw a data type pun?--> week. [\quote]

He was going to need to use a float-ing holiday after this.
[/quote]

This int what I was expecting. I object that they string me along just for a punchline like that! I'll have to double my efforts to come up with a suitable array of ripostes.

Re: Multiplying Strings

2012-12-06 11:56 • by chubertdev
One thing was for certain - this was going to be a long/*Get it? Long...Decimal... When was the last time you saw a data type pun?*/ week.


It's been a Short while.

Re: Multiplying Strings

2012-12-06 12:03 • by Tankster
396586 in reply to 396572
[quote user="very punny"][quote] but one thing was for certain - this was going to be a long<!--Get it? Long...Decimal... When was the last time you saw a data type pun?--> week. [\quote]

He was going to need to use a float-ing holiday after this.
[/quote]

I would string up the developer who did this

Re: Multiplying Strings

2012-12-06 12:04 • by D-Coder
396587 in reply to 396585
How is it that no one had noticed a problem with discounts less than 10% for so long?

Re: Multiplying Strings

2012-12-06 12:25 • by lunaryorn (unregistered)
396588 in reply to 396587
D-Coder:
How is it that no one had noticed a problem with discounts less than 10% for so long?

It seems to be a very generous company... which might explain the quality of the code: There seems to be not enough money left to replace the Office expert dabbling on programming with a real, appropriately paid developer.

Re: Multiplying Strings

2012-12-06 12:26 • by Oscar (unregistered)
396589 in reply to 396587
D-Coder:
How is it that no one had noticed a problem with discounts less than 10% for so long?
Maybe it is one of those shady businesses that marks everything down 40% or more routinely.

Scam alert #1, for you naive youngsters, just in time for the holidays: jewelry stores price their $1000 rings at $2000 then give you "50% off", so you can impress your girlfriend how much you're (not really) spending on her. The problem is, she's much more tuned in to jewelry prices than you are, having spent 20 years now obsessing on the topic. So you're really not fooling her.

Scam alert #2: once you do buy that ring, and complete the related ceremonies, you can start counting down on one hand how many more times in your life you're going to get laid by a hot chick instead of a grudging grump.

Re: Multiplying Strings

2012-12-06 12:37 • by da Doctah
396591 in reply to 396570
Peter Bouillon:
Yes, of course this code is to blame.

* If O.DiscountPercentage is lower than 10, then the calculated discount will off by a factor of 10.

* If O.DiscountPercentage contains a decimal point (e.g. "10.5"), the digits behind it will be lost.

* If O.DiscountPercentage is negative, then "0." & Convert.ToInt32(O.DiscountPercentage) will result in nonsense.


And if O.DiscountPercentage is 100 or greater, the calculated discount will be too small.

Re: Multiplying Strings

2012-12-06 12:39 • by Kae (unregistered)
396592 in reply to 396572
Someone's going to pull some double shifts. It's going to get a bit hectic. But stuff like that builds character. It shows class. Nothing to object to.

Re: Multiplying Strings

2012-12-06 12:44 • by The Big Picture Thinker (unregistered)
396595 in reply to 396573
TheSHEEEP:
Foo Bar:
AGray:
I digress...but, why is it most of the more horrendously stupid WTFs are written in VB? I have never really understood it.

Possibly because some Peters rise up to their level of incompetence by way of:
use MS Office products -> write a macro or two -> hey, that's Visual Basic -> VB programmer.


Also, it is (or was, rather, guess today it is JavaScript) used in many schools for computer science lessons.

Or Java or C#, which is essentially VB with curly brackets

Re: Multiplying Strings

2012-12-06 13:08 • by chubertdev
396599 in reply to 396595
The Big Picture Thinker:
Or Java or C#, which is essentially VB with curly brackets


And case sensitivity. Which is the biggest WTF in any programming language.

Re: Multiplying Strings

2012-12-06 13:56 • by C-Derb (unregistered)
396601 in reply to 396591
da Doctah:
Peter Bouillon:
Yes, of course this code is to blame.

* If O.DiscountPercentage is lower than 10, then the calculated discount will off by a factor of 10.

* If O.DiscountPercentage contains a decimal point (e.g. "10.5"), the digits behind it will be lost.

* If O.DiscountPercentage is negative, then "0." & Convert.ToInt32(O.DiscountPercentage) will result in nonsense.


And if O.DiscountPercentage is 100 or greater, the calculated discount will be too small.
A discount > 100% would be paying someone to take your products off your hands. At that point, you've got bigger problems than string arithmetic.

Re: Multiplying Strings

2012-12-06 13:59 • by eek (unregistered)
396602 in reply to 396572
[quote user="very punny"][quote] but one thing was for certain - this was going to be a long<!--Get it? Long...Decimal... When was the last time you saw a data type pun?--> week. [\quote]

He was going to need to use a float-ing holiday after this.
[/quote]

Your String of data type puns disgusts me.

Re: Multiplying Strings

2012-12-06 14:28 • by Tasty (unregistered)
396603 in reply to 396583
Coyne:
RRDY:
But dividing by 100 is HARD!

captcha: nobis, as in this person had nobis getting anywhere near a computer.


Inefficient, too.

Had a teacher one time that assigned us to minimize parenthesis in something like this:

 A + ((B * C) * (D * E)) / ((F * G) * H)


My response:

 A + B * C * D * E / F / G / H


Whereupon he objected lamely that division was inefficient...but he gave in when I pointed out that the whole objective of the problem was to get rid of parenthesis.


I imagine a modern compiler's optimizer will reduce your code to something more efficient. It's not your father's Fortran anymore.

Re: Multiplying Strings

2012-12-06 14:51 • by foo (unregistered)
396604 in reply to 396583
Coyne:
RRDY:
But dividing by 100 is HARD!

captcha: nobis, as in this person had nobis getting anywhere near a computer.


Inefficient, too.

Had a teacher one time that assigned us to minimize parenthesis in something like this:

 A + ((B * C) * (D * E)) / ((F * G) * H)


My response:

 A + B * C * D * E / F / G / H


Whereupon he objected lamely that division was inefficient...but he gave in when I pointed out that the whole objective of the problem was to get rid of parenthesis.
Assuming these were floating point numbers, he should have objected that you may have changed the result as the associate law doesn't hold. What's safe to remove is:
 A + B * C * (D * E) / (F * G * H)

Re: Multiplying Strings

2012-12-06 14:53 • by A. Nonymous (unregistered)
396605 in reply to 396561
alvatrus:
Which makes *every* poster of *any* top comment a loser by default.

That's why I usually start reading after the frist three or so comments...

Re: Multiplying Strings

2012-12-06 14:56 • by Zylon
I'm not sure "copypasta" means what Mark thinks it means.

Re: Multiplying Strings

2012-12-06 14:56 • by foo (unregistered)
396608 in reply to 396599
chubertdev:
The Big Picture Thinker:
Or Java or C#, which is essentially VB with curly brackets


And case sensitivity. Which is the biggest WTF in any programming language.
Yeah, it really makes more sense to be able to write a program that compiles differently in a Turkish locale. (I'll spare you the details since it's been discussed to often and you can google.)

Re: Multiplying Strings

2012-12-06 15:04 • by j.albert (unregistered)
396610 in reply to 396572
Hopefully he didn't have a short temper...

Re: Multiplying Strings

2012-12-06 15:04 • by foo (unregistered)
396611 in reply to 396602
[quote user="eek"][quote user="very punny"][quote] but one thing was for certain - this was going to be a long<!--Get it? Long...Decimal... When was the last time you saw a data type pun?--> week. [\quote]

He was going to need to use a float-ing holiday after this.
[/quote]

Your String of data type puns disgusts me.[/quote]Sadly, these unsigned comments always follow the same template. Let's go booling.

Re: Multiplying Strings

2012-12-06 15:07 • by chubertdev
396612 in reply to 396608
foo:
chubertdev:
The Big Picture Thinker:
Or Java or C#, which is essentially VB with curly brackets


And case sensitivity. Which is the biggest WTF in any programming language.
Yeah, it really makes more sense to be able to write a program that compiles differently in a Turkish locale. (I'll spare you the details since it's been discussed to often and you can google.)


Did you read "case" as "culture"?

Re: Multiplying Strings

2012-12-06 15:08 • by foxyshadis (unregistered)
396613 in reply to 396560
Well, this guy obviously remember the dictum to never use floats for currency... and picked precisely the wrong solution.

¯\(°_o)/¯ I DUNNO LOL:
TRWTF is that some people shouldn't be allowed near anything that requires 9th grade mathematics skills. This isn't even algebra.

VB? How am I not surprised? (It was either that or PHP.)

Remember when people who should have known better would earnestly claim that javascript had no addition, and that eval(a+"+"+b) was the only way to do it? Because they screwed up and didn't convert strings from the webform into ints, of course.

Re: Multiplying Strings

2012-12-06 15:24 • by foo (unregistered)
396614 in reply to 396612
chubertdev:
foo:
chubertdev:
The Big Picture Thinker:
Or Java or C#, which is essentially VB with curly brackets


And case sensitivity. Which is the biggest WTF in any programming language.
Yeah, it really makes more sense to be able to write a program that compiles differently in a Turkish locale. (I'll spare you the details since it's been discussed to often and you can google.)


Did you read "case" as "culture"?
HTFM.

Case-folding depends on the locale.

Re: Multiplying Strings

2012-12-06 15:26 • by Richard (unregistered)
396616 in reply to 396572
[quote user="very punny"][quote] but one thing was for certain - this was going to be a long<!--Get it? Long...Decimal... When was the last time you saw a data type pun?--> week. [\quote]

He was going to need to use a float-ing holiday after this.
[/quote]

Ha, ha. Very guid.

Re: Multiplying Strings

2012-12-06 15:26 • by Matthew (unregistered)
396617 in reply to 396613
foxyshadis:
Well, this guy obviously remember the dictum to never use floats for currency... and picked precisely the wrong solution.

¯\(°_o)/¯ I DUNNO LOL:
TRWTF is that some people shouldn't be allowed near anything that requires 9th grade mathematics skills. This isn't even algebra.

VB? How am I not surprised? (It was either that or PHP.)

Remember when people who should have known better would earnestly claim that javascript had no addition, and that eval(a+"+"+b) was the only way to do it? Because they screwed up and didn't convert strings from the webform into ints, of course.


eval is evil. The right way to add in JavaScript is
a - -b

Re: Multiplying Strings

2012-12-06 15:27 • by qbolec (unregistered)
396618 in reply to 396604
why can't you drop the parnthesis around D*E as well? Is it because of overflows?

Re: Multiplying Strings

2012-12-06 15:33 • by bjolling
396620 in reply to 396611
foo:
eek:
very punny:
but one thing was for certain - this was going to be a long<!--Get it? Long...Decimal... When was the last time you saw a data type pun?--> week.
He was going to need to use a float-ing holiday after this.
Your String of data type puns disgusts me.
Sadly, these unsigned comments always follow the same template. Let's go booling.
Shirley quoting can't be that hard

Re: Multiplying Strings

2012-12-06 15:37 • by foo (unregistered)
396621 in reply to 396618
qbolec:
why can't you drop the parnthesis around D*E as well? Is it because of overflows?
That, and rounding might be slightly different with a different order of evaluation.

Re: Multiplying Strings

2012-12-06 15:48 • by uns (unregistered)
396622 in reply to 396584
[quote user="Spudley"][quote user="very punny"][quote] but one thing was for certain - this was going to be a long<!--Get it? Long...Decimal... When was the last time you saw a data type pun?--> week. [\quote]

He was going to need to use a float-ing holiday after this.
[/quote]

This int what I was expecting. I object that they string me along just for a punchline like that! I'll have to double my efforts to come up with a suitable array of ripostes.
[/quote]

for real?
« PrevPage 1 | Page 2Next »

Add Comment