arithmetic using a single variable for 2 scores (open &

Discussion of chess software programming and technical issues.

Moderator: Ras

BubbaTough
Posts: 1154
Joined: Fri Jun 23, 2006 5:18 am

arithmetic using a single variable for 2 scores (open &

Post by BubbaTough »

Hi,

I am playing with using a single variable to keep 2 values such as opening and ending weights, and some nice equations posted here earlier that I have now stolen from stockfish (not sure if there was an earlier source or not, but whatever).

Seems to work great on simple tests, but I am looking for some words of warning or some tips on handling special cases. Here are a couple example questions:

1. Does it handle signs ok, or do I need to ensure the numbers in each portion never go negative?
2. Does it support multiplication / division, or do I need to extract the values and reinsert them for this?
3. Are there any other issues I should be aware of?

-Sam
Sven
Posts: 4052
Joined: Thu May 15, 2008 9:57 pm
Location: Berlin, Germany
Full name: Sven Schüle

Re: arithmetic using a single variable for 2 scores (open &a

Post by Sven »

There is a very recent thread named "two values in one integer" here in the programming forum which discusses the topic and also points to earlier threads.

EDIT: Stockfish has implemented multiplication/division support through some C++ operators.

Sven