Thread: Basic questions

Results 1 to 4 of 4
  1. #1
    scimmyboy's Avatar
    Join Date
    Jan 2008
    Gender
    male
    Location
    https://mpgh.net MPGHCash: $442,596,199
    Posts
    5,645
    Reputation
    26
    Thanks
    896
    My Mood
    Happy

    Basic questions

    Code:
    #include "stdafx.h"
    #include <iostream>
    #include <math.h>
    
    using namespace std;
    
    int main()
    {
    	int x;
    	int y;
    	x = 1;
    	y = (1 + (2/x) ) ^ (3 * x);
    	cout << y;
    
    	cin.get();
    	return 0;
    }
    Apparently the compiler does not understand my ^ character. Not sure why that is, even tho i already included the math.h header.

    Anyone care to help?

    BTW, how would a loop be used in order to find values of Y from x = 0-100?

  2. #2
    Retoxified's Avatar
    Join Date
    Feb 2010
    Gender
    male
    Posts
    148
    Reputation
    8
    Thanks
    171
    I asume you want to use ^ for e.g. 4³ being 4*4*4?
    if so thats not what ^ is used for in C++.
    use pow instead:
    Code:
    pow(5,2); //5 to the power of 2

  3. The Following 2 Users Say Thank You to Retoxified For This Useful Post:

    Melodia (04-04-2010),why06 (04-04-2010)

  4. #3
    why06's Avatar
    Join Date
    Jul 2009
    Gender
    male
    Location
    IBM
    Posts
    4,304
    Reputation
    170
    Thanks
    2,203
    My Mood
    Flirty
    ^ in C++ is a bitwise XOR. Also think it does something in MFC (Microsoft Foundation Classes), but who knows. =/

    "Every gun that is made, every warship launched, every rocket fired signifies, in the final sense, a theft from those who hunger and are not fed, those who are cold and are not clothed. This world in arms is not spending money alone. It is spending the sweat of its laborers, the genius of its scientists, the hopes of its children. The cost of one modern heavy bomber is this: a modern brick school in more than 30 cities. It is two electric power plants, each serving a town of 60,000 population. It is two fine, fully equipped hospitals. It is some fifty miles of concrete pavement. We pay for a single fighter plane with a half million bushels of wheat. We pay for a single destroyer with new homes that could have housed more than 8,000 people. This is, I repeat, the best way of life to be found on the road the world has been taking. This is not a way of life at all, in any true sense. Under the cloud of threatening war, it is humanity hanging from a cross of iron."
    - Dwight D. Eisenhower

  5. #4
    Arhk's Avatar
    Join Date
    Dec 2008
    Gender
    male
    Location
    Engineering
    Posts
    3,618
    Reputation
    35
    Thanks
    217
    My Mood
    Amused
    pow() pow() pow()
    ~
    ^_^ admitedly it's a bit annnoying but I'm not sure if you can overload bitwise operators, but you could try to see.
    [php]
    //note the syntax of opertaor overload is remenisant of any functions syntax
    // <type> <name>(<operands>) int main(void) operator ^(&F, &S)
    // we need the memory addresses for this to work like an actual operator
    //which require the = sign
    operator ^(<type> &F, <type> &S)
    {
    //code to work with operands F,S
    }
    operator ^(double, double);
    operator ^(int, int);
    int main()
    {
    int n;
    n = 5^6;
    ....
    ......
    }
    [/php]

    I considered the idea of writing it out for you, but operator overloading is something you should go learn about if you don't already know. I guess copying from code from the actual pow() function in the header would help. Operator overloading would also allow you to make a "better" version of
    pow() since it only provides support for int values. Considering powers with double values would cause(many) inaccuracies it might be necessary that you have it truncate float values.
    Also for versatility you might having to run into the OOP idea of templates.
    Last edited by Arhk; 04-04-2010 at 08:13 AM.
    "If the world hates you, keep in mind that it hated me first." John 15:18

Similar Threads

  1. Quick basic question.
    By ~AfroNinja~ in forum CounterStrike (CS) 1.6 Hacks / Counter Strike: Source (CSS) Hacks
    Replies: 5
    Last Post: 07-24-2010, 10:48 AM
  2. Basics Of Modding, Question
    By guitarhero192 in forum Combat Arms Help
    Replies: 2
    Last Post: 07-05-2010, 02:20 AM
  3. [Question] Visual Basics Keylogger
    By Pixie in forum Visual Basic Programming
    Replies: 10
    Last Post: 11-30-2009, 09:22 PM
  4. Visual Basic question
    By steven_italy in forum Visual Basic Programming
    Replies: 14
    Last Post: 03-09-2008, 07:29 AM
  5. visual basic questions
    By nikryj in forum WarRock - International Hacks
    Replies: 4
    Last Post: 02-24-2008, 03:30 PM