Odds conversion functions

November 4, 2008

Odds conversion is something you will hardly ever need. For most it would be sufficient to use a conversion tables.

But if you actually need to convert odds as part of a script here is how to do so:

There are three types of odds format:

  • Fractional: 9/5 for every 5 dollars you invest you get 9 if you win and the original 5 stake.
  • Decimal: 2.8 for every dollar you invest you get 2.8 dollars, that include the original stake.
  • American: American odds are divided to two parts positives and negatives.
    Positive: 180 for every $100 you invest you win $180 and get your $100 stake back.
    Negative: -180 to win $100 you need to invest $180, so if you invest $180 and win you get $100 and the $180 stake back.

Conversion between odds is rather simple.

Given the fractional odds numerator/denominator ( for short: num/den)
The decimal odds are computed as decOdds = ((num+den)/den)
The American odds are computed as follow
if (num/den > 1 )
    usOdds = ((num/den)*100)
else
    usOdds = ((den/num)*(-100))


RIM development environment serial port

October 16, 2008

I am developing a handheld application for my company. and it on a blackberry device. basically it’s a device programmer interfacing through a serial port. since blackberrys do not have serial port I’ll be using a Bluetooth to serial port converter, but for development I can use the BB serial port emulation through the PC port.

At first I use the class connector interface to open a serial port, as they use in their samples. but I couldn’t get it to accept messages coming over the port, I spent hours on that, tweaking the port and the code, nothing. The DataInputStream.available() always return zero, although I know it got a response. Eventually I found a different class, oddly enough named Class SerialPort that worked perfectly well. RIM did advised not to use it, but I am not going to use it for the final product anyway.


First steps with blogging

October 16, 2008

First part of writing a blog is opening an account. That was way too complicated: at first I wanted to open one in some technology site so others can find this information, after a long search I found toolbox but it seems that they only want good writers and they may not accept me as one. Well, I’m not gona be tested on my writing skills, that not my strength anyway. I search more, but haven’t found anything. I could open it in blogger or any of the massive blogging sites but I wanted a technology title, Engineers don’t look for solutions in Blogger…

Eventually I decided to open a blog in my own site, simple and straight forward. My hosting provider have wordpress ready to install, click clack and it’s running.

Now I had to add a bit of personal touch, so I downloaded a theme that suits me, tweaked it a bit and here you go.


My First Post

October 14, 2008

Welcome!

My name is Raz and I am a software engineer for 10 years now. As an engineer I am having challenges on daily basis, most are simple, easy and resolved by employing my knowledge and experience, Some are more difficult and require investigation, usually googling the problem and find the solution in over the web, and the last are challenges that it seems I’m the first to encounter or, to be more modest, no one ever post the solution on the web.

In general, I believe that sharing the knowledge on the web is important and so I decided to describe the third type challenges and solutions in my own blog, for others to enjoy.

This blog is not about me, it not going to be personal or interesting, just a list of facts and experiences that others can find and use in there challenges.