You should be able to solve this

you should be able to solve this

What is a "function"?

this question is outside the scope of the thread. please do not troll

In C++ it's just
int i;
std::cin >> i;
std::cout

...

Maki is a nerd!

they railtrail

>converts integer from decimal to binary
So... it's a change of base? Is this supposed to be a function int -> int? Or are we looking for a string that represents the number in binary, or...

Your image is wrong. Cristina is actually smart, Maki sells her body to old men for money.

thats a repulsive thing to say. please delete your post

Is this the missing fifth fact???!?!?!1!1111?!!?!11??!?

Gross

Since it says arithmetic operators, are bit operations allowed?
Because "/= 2" does not do the same as ">> 1" for negative values.
std::string to_binary(int val){
int cnt = sizeof(val)*8;
std::string res(cnt, '0');
while(cnt --> 0){
if(val & 1)
res.at(cnt = '1');
val = val >> 1;
}
return res;
}

No, this is

>res.at(cnt = '1');
should be res.at(cnt) = '1';
obviously.

delet

I deleted Maki's virginity.

DELETDELETDELET

unless you're expecting the string representation of the negated signed int, how is this any more than just negating a signed int...

Lies, she told me I was the first one.

thats exactly what you're doing. the puzzle is to write a function that given "5" returns "0101" and given "-5" returns "1011". with math, not builtins. like you were doing it by hand.

int baka(int x) {
return x;
}


What do I win?

you must donate $5 to the electronic frontier foundation

In hand, I would also just use right shift over whatever satisfies your need for "math".
I don't really see the point in your homework

then what?

>only math
What do you think the computer does?

Are we only allowed to use ( +, -, *, -) directly?

What about log, etc

how would you do that? I'd convert, say, 76, to binary by thinking to myself "ok, so 64 is the greatest value that will fit, and i'm short 12, so I'll write a 1 in the 2^6 place, 0 in 2^5, 0 in 2^4, 1 in 2^3, 1 in 2^1 0 in 2^1, and 0 in 2^0. I'll add the sign bit and get 01001100". that's what i learned in school anyway

and for negative 76 I'd do the exact same thing, then invert all bits excepting the last one and write 10110010. the question was if Sup Forums could come up with a program that does the same thing. i thought that was pretty obvious but dang, who knows

my function is
I am personally not that fast at calculating stuff, so if I were to solve it by hand, I would write down all the 2^n bits I needed, then subtract the bit I am at and write 1 or write 0 if less.
This function only works for positive numbers but it is closer to what I would do in hand.
std::string to_binary(int val){
int cnt = sizeof(val)*8;
int max = cnt -1;
std::string res(cnt,'0');
while(cnt --> 0){
int ex = 2 = ex){
res.at(max-cnt) = '1';
}
}
}

5 cute facts about maki:

- She's a girl!?
- She's a tomato!
- I love her!!!!!
- Maki!!!!!!!!!!!