do a simple maths problem

News and important info, general banter, and suggestions for 5punk

Moderator: Forum Moderators

deject
Berk
Berk
Posts: 10353
Joined: December 7th, 2004, 17:02
Location: Oklahoma City, OK, USA
Contact:

Post by deject »

Huh. That may be the compiler you're using or something because I'm pretty sure that it wasn't like that to begin with.
Baliame
Tremors Worm
Tremors Worm
Posts: 3491
Joined: October 13th, 2007, 23:43
Location: Hungary

Post by Baliame »

It's not the compiler, check the link. :)

In fact, surprisingly the Microsoft Visual compiler is currently one of most convention-compliant compilers today.

Lawyered. :P
buzzmong
Weighted Storage Cube
Weighted Storage Cube
Posts: 7167
Joined: February 26th, 2007, 17:26
Location: Middle England, nearish Cov

Post by buzzmong »

Bubbles is correct.

C++ reads left to right for operations of the same precedence.
Baliame
Tremors Worm
Tremors Worm
Posts: 3491
Joined: October 13th, 2007, 23:43
Location: Hungary

Post by Baliame »

buzzmong wrote:C++ reads left to right for operations of the same precedence.
While correct, it's entirely not what we were debating! :P
buzzmong
Weighted Storage Cube
Weighted Storage Cube
Posts: 7167
Joined: February 26th, 2007, 17:26
Location: Middle England, nearish Cov

Post by buzzmong »

Essentially, yes it is.

It would be best to show it in a parse tree so you can clearly see what's happening, but I cannot be fucked to draw one and have no intention of ever doing one again narf.
HereComesPete
Throbbing Cupcake
Throbbing Cupcake
Posts: 10249
Joined: February 17th, 2007, 23:05
Location: The maleboge

Post by HereComesPete »

Okay, you all need to stop C++ock waving and make a main stream 5punk game that infects the minds of millions damn it!
Baliame
Tremors Worm
Tremors Worm
Posts: 3491
Joined: October 13th, 2007, 23:43
Location: Hungary

Post by Baliame »

As a matter of fact it is a 2D engine I'm working on, it could be magically transform into a game if you can come up with something absolutely mind-blowing.

Buzz: I know it does this weird thing which has a name which absolutely escapes me, like for the problem above: 1 3 4 * - 7 +.
Last edited by Baliame on June 18th, 2010, 21:59, edited 1 time in total.
buzzmong
Weighted Storage Cube
Weighted Storage Cube
Posts: 7167
Joined: February 26th, 2007, 17:26
Location: Middle England, nearish Cov

Post by buzzmong »

How about a game of blowing minds? With air horns. Or vuvuulvuuzuzubzbbbzzzzzzzzzzzzbzzzzzzzzzzz thiniges.
Stoat
Site Admin
Site Admin
Posts: 3291
Joined: October 8th, 2004, 15:48
Location: Sheffield, UK
Contact:

Post by Stoat »

buzzmong wrote:How about a game of blowing minds? With air horns. Or vuvuulvuuzuzubzbbbzzzzzzzzzzzzbzzzzzzzzzzz thiniges.
[media]http://www.youtube.com/watch?v=7B2LPxggvqY[/media]
Mr. Johnson
Mr Flibbles
Mr Flibbles
Posts: 4957
Joined: August 10th, 2006, 10:58
Location: belgium

Post by Mr. Johnson »

You guys seen the new frontpage right?
buzzmong
Weighted Storage Cube
Weighted Storage Cube
Posts: 7167
Joined: February 26th, 2007, 17:26
Location: Middle England, nearish Cov

Post by buzzmong »

Stoat wrote: [media]http://www.youtube.com/watch?v=7B2LPxggvqY[/media]
Hahaha, that was brilliant!
HereComesPete
Throbbing Cupcake
Throbbing Cupcake
Posts: 10249
Joined: February 17th, 2007, 23:05
Location: The maleboge

Post by HereComesPete »

Mr. Johnson wrote:You guys seen the new frontpage right?

THE BEES!


NOT THE BEES!


OH GOD THE BEES!


THEY'RE WEARING A BEAR SUIT!
FatherJack
Site Owner
Site Owner
Posts: 9597
Joined: May 16th, 2005, 15:31
Location: Coventry, UK
Contact:

Post by FatherJack »

C++ does indeed give -4
Image
It's documented as having + above - in its operator preferences, but actually treats them equally - perhaps, as deject mentioned, because they are essentially the same operation.

In terms of what I was taught, it was to never write equations ambiguously, or at least I learned that at some point. While I did maths into college level, it's later that I did programming, so I guess it's that methodology that has stuck with me.
cheeseandham
Shambler In Drag
Shambler In Drag
Posts: 780
Joined: March 16th, 2007, 20:22
Location: on the sofa
Contact:

Post by cheeseandham »

-4

and I'm right, so end of discussion :P
Baliame
Tremors Worm
Tremors Worm
Posts: 3491
Joined: October 13th, 2007, 23:43
Location: Hungary

Post by Baliame »

Just to clear it up once and for all, C++ has 16 tiers for operators
1. Scope
2. Brackets and casts
3. Unary operations (negation, increment, logical NOT, pointer denomination, etc.)
4. Pointer resolution
5. Multiplication, division, modulo
6. Addition, subtraction
7. Shift
8. Less/greater than
9. Equal and not equal
10-11-12. Bitwise AND / Bitwise XOR / Bitwise OR
13-14. Logical AND / Logical OR
15. Conditional operator
16. Assignment (=, +=, *=...)

TL;DR Deej should consider using a proper compiler.
shot2bits
Zombie
Zombie
Posts: 2082
Joined: February 7th, 2005, 17:40
Location: england

Post by shot2bits »

Stoat wrote: [media]http://www.youtube.com/watch?v=7B2LPxggvqY[/media]
you cupcake!

this made me splutter tea over my new keyboard
deject
Berk
Berk
Posts: 10353
Joined: December 7th, 2004, 17:02
Location: Oklahoma City, OK, USA
Contact:

Post by deject »

You know what, I'm probably being a dumb spanner because I remember now that C++ will look at the entire expression first. It's Java that will do it wrong.
Anhamgrimmar
Ninja Pirate
Ninja Pirate
Posts: 1517
Joined: July 17th, 2005, 13:29
Location: Saaaarfampton

Post by Anhamgrimmar »

Yes well, this is all to the good, but WHERE DID THE OTHER POUND GO?
Baliame
Tremors Worm
Tremors Worm
Posts: 3491
Joined: October 13th, 2007, 23:43
Location: Hungary

Post by Baliame »

deject wrote:It's Java that will do it wrong.
I wouldn't be surprised, Java is evil.
FatherJack
Site Owner
Site Owner
Posts: 9597
Joined: May 16th, 2005, 15:31
Location: Coventry, UK
Contact:

Post by FatherJack »

Stoat wrote: [media]http://www.youtube.com/watch?v=7B2LPxggvqY[/media]
Heh, I liked them poking through the door, but if only they were so tuneful.
Post Reply