Jump to content

  • Log In with Google      Sign In   
  • Create Account


nimrodson

Member Since 13 Feb 2012
Offline Last Active Aug 23 2013 06:33 PM

Posts I've Made

In Topic: FADD vs FMUL time

17 April 2013 - 08:38 PM


A lot of operations can be hard wired to complete in a single clock cycle, if you throw enough transistors at it.

 

FDIV operation still be too slow compared to FADD-FMUL. That means FDIV requires too much transistors to approach to FADD-FMUL times?


In Topic: FADD vs FMUL time

17 April 2013 - 08:32 PM

Are you asking for the specifics of the floating point ALU? That's getting pretty deep, man. I'd be curious to see it if anyone has access to that info.

 

Maybe: My interest lies on to know the hardware-algorithmics aspects behind the add and mul operations, regardless if those operations are performed in the FPU or not.


In Topic: Traversing a List of Vectors

06 April 2013 - 02:13 PM

If you're using C++11, you can try this too:

 

#include <vector>
#include <list>
#include <iostream>

int main()
{
  std::list<std::vector<int>> listVectors{{1,2,3},{4,5,6},{7,8,9}};
  for ( auto& vec : listVectors )
    for ( int& i : vec )
      //process each int i
      std::cout << i << std::endl;
}


In Topic: Three of a kind numbers

01 April 2013 - 02:20 PM

Just for fun, a (beginner) Haskell implementation:

 

unique :: (Eq a) => [a] -> [a]
unique []     = []
unique (x:xs) = x : unique (filter (\y -> not (x==y)) xs)

nOcurrences :: (Eq a) => a -> [a] -> Int
nOcurrences elem list = length (filter (==elem) list)

isThreeKind :: (Eq a) => [a] -> Bool
isThreeKind list = elem 3 [nOcurrences i list | i <- (unique list)]

You could parametrize the 3 number in "isThreeKind" function and have a "fourKind", a "fiveKind", or whatever...

Cheers.


In Topic: Object was not declared in this scope?

29 March 2013 - 10:39 AM

When you doing this:
 
 

// creating the object
if(event.button.button==SDL_BUTTON_LEFT) bullet myBullet(90, 530, 20, -20, 1);

 
You're using *automatic* (EDITED, thanks @rip-off. Don't confuse with "auto" C++11 reserved word) declaration -> allocation on the variable "myBullet". That means (among other things) that the "myBullet" timelife remains in the scope in which that variable was declared, in this case, the precedent if statement. When the if statement is consumed, all the *automatic* resources inside the "if" scope are destroyed, including "myBullet". That is the reason why "myBullet.update()" is undefined, because there's no declaration of "myBullet" in the present scope or an outter scope (When you comment out the first line, myBullet declaration, this is in a outter scope, and therefore works). 
What you need to do is using dynamic allocation, something like the solutions presented by the others members.

PARTNERS