generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripters
Home Search
 

Re: Which way is more efficient in C++?

Previous Thread :: Next Thread 
BrontoByte is not online. BrontoByte
Joined: 26 Feb 2012
Total Posts: 319
21 Mar 2012 06:23 AM
For determining if it's a long int/unsigned int

int Literals1 = 76u
int Literals2 = 76l
int Literals3 = 76ul

or something like

unsigned Literals4 = 76
long Literals5 = 76
Report Abuse
stravant is not online. stravant
Forum Moderator
Joined: 22 Oct 2007
Total Posts: 2893
21 Mar 2012 07:51 AM
Not sure what you mean by "determining if".

Regardless, in the end how you write the thing won't matter (as long as it's written correctly of course), how you write it exactly. C+++ has very good optimization, so pretty much whatever obvious way of doing it (You can make something convoluted enough to fool the optimizer, but you usually have to be trying to do that for it to happen) you choose the optimizer will get it down to the same minimal code.
Report Abuse
TheMyrco is not online. TheMyrco
Joined: 13 Aug 2011
Total Posts: 15105
21 Mar 2012 08:27 AM
I recommend doing the second way tough, better to see :)
Report Abuse
Bubby4j is not online. Bubby4j
Joined: 25 Dec 2008
Total Posts: 1831
21 Mar 2012 08:33 AM
@stravent
What's C+++? His question was on C++.
Report Abuse
BrontoByte is not online. BrontoByte
Joined: 26 Feb 2012
Total Posts: 319
21 Mar 2012 08:43 AM
@stravant

Oh so it doesn't matter?

And I meant "if" because when you make an int you have to define if it's like a small integer, a large integer, or if it's an unsigned integer, etc.
Report Abuse
myrkos is not online. myrkos
Joined: 06 Sep 2010
Total Posts: 8072
21 Mar 2012 09:26 AM
The only way that works is:

unsigned int x;

long x; // Usually the same as int

short x; // half int

char x;

unsigned char x;
Report Abuse
BrontoByte is not online. BrontoByte
Joined: 26 Feb 2012
Total Posts: 319
21 Mar 2012 05:58 PM
@myrkos

No, on the C++ documentation, it's called a constant, and if you add like a U or an L to the end of the number, it will become a long or unsigned int.
Report Abuse
myrkos is not online. myrkos
Joined: 06 Sep 2010
Total Posts: 8072
21 Mar 2012 05:58 PM
That doesn't affect the size of the variable.
Report Abuse
BrontoByte is not online. BrontoByte
Joined: 26 Feb 2012
Total Posts: 319
21 Mar 2012 05:59 PM
http://www.cplus
plus.
com/doc/tutorial/constants/
Report Abuse
myrkos is not online. myrkos
Joined: 06 Sep 2010
Total Posts: 8072
21 Mar 2012 06:00 PM
Still doesn't affect the size or type of the variable.

What you're doing is changing the type of the constant that the variable gets assigned to, but in your examples the variable is always an int and the constant will just be converted to an int.
Report Abuse
BrontoByte is not online. BrontoByte
Joined: 26 Feb 2012
Total Posts: 319
21 Mar 2012 06:05 PM
so adding a literal is useless

wat
Report Abuse
myrkos is not online. myrkos
Joined: 06 Sep 2010
Total Posts: 8072
21 Mar 2012 06:07 PM
Pretty much in this case, but it is when you're adding various numbers and want, for instance, different accuracy if you're working with floating point or whatever.
Report Abuse
enumeration is not online. enumeration
Joined: 17 Dec 2011
Total Posts: 2552
21 Mar 2012 06:35 PM
[ Content Deleted ]
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image