harbour Math Difference ?

General Help regarding HMG, Compilation, Linking, Samples

Moderator: Rathinagiri

Post Reply
User avatar
AUGE_OHR
Posts: 2117
Joined: Sun Aug 25, 2019 3:12 pm
DBs Used: DBF, PostgreSQL, MySQL, SQLite
Location: Hamburg, Germany

harbour Math Difference ?

Post by AUGE_OHR »

hi,

this was my working Code

Code: Select all

   Row1 := Height/6*5
   Col1 := Width /6*5
   Row2 := Height/6*1
   Col2 := Width /6*1
than i try this

Code: Select all

   nRing := 3 
   Row1 := Height/nRing*2*5
   Col1 := Width /nRing*2*5
   Row2 := Height/nRing*2*1
   Col2 := Width /nRing*2*1
but it does not work :o

so i try

Code: Select all

   Row1 := Height/(6*5)
   Col1 := Width /(6*5)
   Row2 := Height/(6*1)
   Col2 := Width /(6*1)
and now "this" also does not work :shock:

i did more test and found this Solution

Code: Select all

   nRing := 3 
   Row1 := Height/(nRing*2)*5
   Col1 := Width /(nRing*2)*5
   Row2 := Height/(nRing*2)*1
   Col2 := Width /(nRing*2)*1
but i still confused about Different Result
for my xBase Knowhow all seems to have sane Result, or :?:
have fun
Jimmy
edk
Posts: 999
Joined: Thu Oct 16, 2014 11:35 am
Location: Poland

Re: harbour Math Difference ?

Post by edk »

Hi Jimmy.
You are asking about elementary rules of mathematical operations. In primary school, they teach that there are four basic math operations: division, multiplication, addition and subtraction. According to mathematical rules, individual calculations must be performed in the right order: first we perform calculations in parentheses, then outside the parentheses in the following order: division, then multiplication, and finally addition and subtraction. We perform the calculations from left to right.
Let's see it in the example we're discussing.
For the sake of calculations, assume that the variable "Height" is equal to 30 and nRing = 3.
1. Row1: = Height / 6 * 5 => 30/6 * 5 => 5 * 5 = 25
2. Row1: = Height / nRing * 2 * 5 => 30/3 * 2 * 5 => 10 * 2 * 5 => 20 * 5 = 100
3. Row1: = Height / (6 * 5) => 30 / (6 * 5) => 30/30 = 1
4. Row1: = Height / (nRing * 2) * 5 => 30 / (3 * 2) * 5 => 30/6 * 5 => 5 * 5 = 25
User avatar
AUGE_OHR
Posts: 2117
Joined: Sun Aug 25, 2019 3:12 pm
DBs Used: DBF, PostgreSQL, MySQL, SQLite
Location: Hamburg, Germany

Re: harbour Math Difference ?

Post by AUGE_OHR »

hi,

you are right, sometimes i forgot rules of mathematical operations ... :roll:
have fun
Jimmy
Post Reply