Page 1 of 1

Change a number -1

Posted: Sat May 13, 2006 6:32 pm
by ianhull
How would I change a number minus 1?

I have a number 99 and I need to take away 1 to make it 98

please help.

Posted: Sat May 13, 2006 6:49 pm
by hawleyjr

Code: Select all

$myVar = 99;
$myVar--;
echo $myVar;

Posted: Sat May 13, 2006 8:37 pm
by alex.barylski
Aren't questions like that illegal? :P

I'm sorry, but that is the most trivial programming related question I have ever heard...

If you couldn't figure that out it's because you haven't even glanced at a book or article, etc...

If your under 16...I forgive you...and apologize and suggest you pick up a book...if not...then I just kicked you in the shins :P

Cheers :)

Posted: Sat May 13, 2006 10:04 pm
by RobertGonzalez
Not everyone here is a coding genius. Heck, some don't even have a grasp on the logic. I'd agree that the OP probably didn't do a lick of searching for the answer before posting. But cut him some slack. Most of us around here (myself included) have asked some pretty trivial, almost stupid, questions at some time or another. :wink:

Posted: Sat May 13, 2006 10:14 pm
by Benjamin
Ok so we learned how to subtract one. What if we wanted to subtract 2 :wink:

Posted: Sat May 13, 2006 10:34 pm
by Charles256

Code: Select all

$original_number=99;
$number_to_subtract=2;
$resulting_number=$original_number-$number_to_subtract;
echo "$original_number minus $number_to_subtract equals $resulting_number";
now that was fun :-D

Posted: Sat May 13, 2006 11:23 pm
by alex.barylski
Everah wrote:Not everyone here is a coding genius. Heck, some don't even have a grasp on the logic. I'd agree that the OP probably didn't do a lick of searching for the answer before posting. But cut him some slack. Most of us around here (myself included) have asked some pretty trivial, almost stupid, questions at some time or another. :wink:
Coding genius? :?

Any value minus another is such a basic skill...and the required operator and 2 essential operands...

I'm sorry, but IMHO thats so basic...it's frustrating...

While I agree...there is no such thing as a stupid question...this one was at the very least almost rhetorical...

The answer would be given in almost any article or book if he/she would have read past the books preface...

I only harp because it's screams "I'm overly anxious or really lazy" in which case...my opinion IMHO was needed :P

Cheers :)

Posted: Sat May 13, 2006 11:41 pm
by hawleyjr
Stay on topic... :?

Posted: Sat May 13, 2006 11:43 pm
by RobertGonzalez
I agree with you in every regard. The only thing I would add (not really to rebut you, just to note) is that eventhough someone knows the process to achieve something in one medium does not mean that they can do it in another. Say I know that the difference between two numbers is the greater of the two less the lesser of the two. I can do this in plain, simple written math. However, I don't know how to do it in some other language (say PHP, ASP, Cobol, Ruby, Python or anything else). So I ask. Like the original poster.

But I am totally in agreement with you. This is probably one of the easier things to find using google. If one would try...

EDIT: Sorry about this post coming in after the last one.

Posted: Sun May 14, 2006 12:09 am
by alex.barylski
Staying on topic and being productive: http://www.developer.com/lang/php/article.php/938511

Read it...it's good for you...like chicken soup when your sick ;)

Posted: Sun May 14, 2006 12:12 am
by alex.barylski
Aghhh....

Despite you having 85 posts under your name...IMHO you should really know better...

I apologize for biting like I did...

I genuinely feel like a dork now :P

Cheers :)