Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.clipper.visual-objects > #5283 > unrolled thread

Shortint calculations

Started bykvstegemann@web.de
First post2013-05-27 08:53 -0700
Last post2013-05-31 03:43 -0700
Articles 4 on this page of 24 — 8 participants

Back to article view | Back to comp.lang.clipper.visual-objects


Contents

  Shortint calculations kvstegemann@web.de - 2013-05-27 08:53 -0700
    Re: Shortint calculations Karl Faller <mail_withoutthat_@_drei-f_andthat_.de> - 2013-05-27 18:09 +0200
    Re: Shortint calculations dlzc <dlzc1@cox.net> - 2013-05-27 10:21 -0700
      Re: Shortint calculations Karl Faller <mail_withoutthat_@_drei-f_andthat_.de> - 2013-05-27 20:32 +0200
      Re: Shortint calculations kvstegemann@web.de - 2013-05-27 11:46 -0700
        Re: Shortint calculations Karl Faller <mail_withoutthat_@_drei-f_andthat_.de> - 2013-05-27 23:40 +0200
        Re: Shortint calculations "Wolfgang Riedmann" <wriedmann@gmail.com> - 2013-05-28 08:02 +0200
    Re: Shortint calculations Mathias <mathias.hakansson@consultec.se> - 2013-05-27 22:39 -0700
      Re: Shortint calculations Karl Faller <mail_withoutthat_@_drei-f_andthat_.de> - 2013-05-28 09:01 +0200
        Re: Shortint calculations kvstegemann@web.de - 2013-05-28 01:02 -0700
          Re: Shortint calculations Karl Faller <mail_withoutthat_@_drei-f_andthat_.de> - 2013-05-28 10:32 +0200
            Re: Shortint calculations kvstegemann@web.de - 2013-05-28 01:46 -0700
      Re: Shortint calculations Meinhard Schnoor-Matriciani <msm@appfact.de> - 2013-05-28 11:45 +0200
        Re: Shortint calculations Mathias <mathias.hakansson@consultec.se> - 2013-05-28 23:45 -0700
          Re: Shortint calculations "Er!k \\/!$$Er" <nospam@nospam.url> - 2013-05-29 16:57 +0200
            Re: Shortint calculations dlzc <dlzc1@cox.net> - 2013-05-29 09:33 -0700
    Re: Shortint calculations dlzc <dlzc1@cox.net> - 2013-05-28 07:15 -0700
      Re: Shortint calculations Mathias <mathias.hakansson@consultec.se> - 2013-05-29 04:44 -0700
        Re: Shortint calculations dlzc <dlzc1@cox.net> - 2013-05-29 07:25 -0700
    Re: Shortint calculations "Jamal" <jamal@examples.net> - 2013-05-29 17:18 -0400
      Re: Shortint calculations kvstegemann@web.de - 2013-05-30 01:47 -0700
        Re: Shortint calculations "Jamal" <jamal@examples.net> - 2013-05-30 13:19 -0400
    Re: Shortint calculations Meinhard Schnoor-Matriciani <msm@appfact.de> - 2013-05-30 22:05 +0200
      Re: Shortint calculations kvstegemann@web.de - 2013-05-31 03:43 -0700

Page 2 of 2 — ← Prev page 1 [2]


#5307

Fromkvstegemann@web.de
Date2013-05-30 01:47 -0700
Message-ID<a168c874-1b2f-4438-93f2-33ed3dbfa607@googlegroups.com>
In reply to#5305
Am Mittwoch, 29. Mai 2013 23:18:10 UTC+2 schrieb Jamal:
> So try putting the complex expression part in left hand of the comparison.

Jamal,
there's really no more need of another workaround. If I want a workaround, I just use longints. The question is, where to use workarounds? What exactly is broken? Is it the > operator with shortints? Is it the evaluation of simple operations like subtractions with shortints? (Not really a "complex expression" ...) Is it an exotic combination of expressions?

I hope Meinhard finds out, so that we can spot the places where a workaround is needed. And then of course, a fix would be nice.

Have a nice day
Kay-Viktor

[toc] | [prev] | [next] | [standalone]


#5310

From"Jamal" <jamal@examples.net>
Date2013-05-30 13:19 -0400
Message-ID<ko81m4$7k7$1@speranza.aioe.org>
In reply to#5307
Kay-Victor,

Good luck waiting for a solution. The compiler people like Fru left the Dev 
team since CA abandoned the product.

Jamal

wrote in message 
news:a168c874-1b2f-4438-93f2-33ed3dbfa607@googlegroups.com...

Am Mittwoch, 29. Mai 2013 23:18:10 UTC+2 schrieb Jamal:
> So try putting the complex expression part in left hand of the comparison.

Jamal,
there's really no more need of another workaround. If I want a workaround, I 
just use longints. The question is, where to use workarounds? What exactly 
is broken? Is it the > operator with shortints? Is it the evaluation of 
simple operations like subtractions with shortints? (Not really a "complex 
expression" ...) Is it an exotic combination of expressions?

I hope Meinhard finds out, so that we can spot the places where a workaround 
is needed. And then of course, a fix would be nice.

Have a nice day
Kay-Viktor 

[toc] | [prev] | [next] | [standalone]


#5311

FromMeinhard Schnoor-Matriciani <msm@appfact.de>
Date2013-05-30 22:05 +0200
Message-ID<51a7b3da$0$6626$3ca0ca56@newsspool2.vodafone-ip.de>
In reply to#5283
Hi Kay-Victor,

just looked into the compiler to see what happens here. Roughly spoken 
it happens the following (it is quite tricky to find these things out as 
there is nearly no documentation) :

- the arithmetic expression is being evaluated on 32bit base even 
shortints are only 16bits

- the comparison is done by using the right hand intermediate datatype 
which is dword in this case ( which is wrong I admit, internally the 
32bit registers are used and the values in there are just dwords ) I you 
example a value of 0xfffff3 is used for the comparison and this is the 
reason while the comparison fails

If you turn it the other way round ( nB - nC ) <= nA it works because 
the result of (nB-nC) get converted to SHORTINT before the comparison 
takes place because the right hand part results in the datatype SHORINT.

Another, abstruse way, to get around the problem is to use

IF nA > SHORTINT(DWORD((nB - nC ))) ....

I have checked the old versions as well and this problem is there at 
least since 2.0 ....

Regards
Meinhard

Am 27.05.2013 17:53, schrieb kvstegemann@web.de:
> FUNCTION Start()
>
> 	LOCAL nA, nB, nC AS SHORTINT
> 	
> 	nA := 748
> 	nB := 22
> 	nC := 35
> 	
> 	IF nA > ( nB - nC )
> 		? "748 is greater than (22 - 35)"
> 	ELSE
> 		? "748 is not greater than (22 - 35). Oops!"
> 	ENDIF
> 	
> 	_Wait("")


-- 
Meinhard Schnoor-Matriciani
Grafx Development Team

[toc] | [prev] | [next] | [standalone]


#5312

Fromkvstegemann@web.de
Date2013-05-31 03:43 -0700
Message-ID<9fc4c357-04af-4e48-9abf-c75c5b63ea94@googlegroups.com>
In reply to#5311
Hi Meinhard,

thanks for checking that. So when I want to play it safe, I could say as a rule of thumb, "don't use expressions containing shortints on the right side of a comparison operator". Right?

In other words, I could prevent this sort of problem by either
- not using shortints at all, or
- evaluating shortint expressions into a separate variable before applying a comparison operator (The "nD" approach :)

Have a nice weekend
Kay-Viktor

[toc] | [prev] | [standalone]


Page 2 of 2 — ← Prev page 1 [2]

Back to top | Article view | comp.lang.clipper.visual-objects


csiph-web