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


Groups > comp.lang.clipper.visual-objects > #5303

Re: Shortint calculations

From "Er!k \\/!$$Er" <nospam@nospam.url>
Newsgroups comp.lang.clipper.visual-objects
Subject Re: Shortint calculations
Date 2013-05-29 16:57 +0200
Organization Netfront http://www.netfront.net/
Message-ID <ko5503$2lr5$1@adenine.netfront.net> (permalink)
References <aa22a440-8e92-444c-9538-3488ccce999d@googlegroups.com> <456106ce-3950-46bd-9800-de8543f5df72@googlegroups.com> <51a47d2d$0$6643$3ca0ca56@newsspool2.vodafone-ip.de> <018d375d-3c3f-4ba3-ab4f-a5075a8f4072@googlegroups.com>

Show all headers | View raw


Mathias,

I have tried this code on VO 2.6, VO 2.7 build 2773 and VO 2.8 build 2837 
and it works fine here.

Erik

-13
-13
748
.F.
.T.
.T.
748 is greater than (22 - 35)




"Mathias"  schreef in bericht 
news:018d375d-3c3f-4ba3-ab4f-a5075a8f4072@googlegroups.com...

Hi Meinard,

I suspected that usuals don't carry shortints. However the whole thing is 
very confusing and it gets even more confusing if I modify the testprogram 
like below. It seems like it works if I calculate the subtraction before 
comparing.

function Start()
local nA, nB, nC, nD as shortint

nA := 748
nB := 22
nC := 35

nD := nB - nC

? nB - nC // -13
? nD // -13
? nA // 748
? nA > nB - nC // .F.
? nA > nD // .T.
? longint(nA) > ( nB - nC ) // .T.

        if longint(nA) > nB - nC
                ? "748 is greater than (22 - 35)"
        else
                ? "748 is not greater than (22 - 35). Oops!"
        endif

        _Wait("")


return nil



Den tisdagen den 28:e maj 2013 kl. 11:45:31 UTC+2 skrev Meinhard 
Schnoor-Matriciani:
> Mathias,
>
>
>
> this approach must lead to confusions, because UsualType would never
>
> return something like Shortint ( see documentation ).
>
>
>
> I am going to have a look at this.
>
>
>
> Regards
>
> Meinhard
>
>
>
> Am 28.05.2013 07:39, schrieb Mathias:
>
> > This sample may be en explanation, but I still Think it's very 
> > confusing. It seems like if all the numbers are longints. But maybe only 
> > nb - nC is a longint and something goes wrong when comparing a shortint 
> > and a longint in nA > ( nB - nC )?
>
> >
>
> > /Mathias
>
> >
>
> > function Start()
>
> >     local nA, nB, nC as shortint
>
> >
>
> >     nA := 748
>
> >     nB := 22
>
> >     nC := 35
>
> >
>
> >
>
> >
>
> > ? "Shortint?"
>
> > ? UsualType(nB - nC) == shortint
>
> > ? "Longint?"
>
> > ? UsualType(nB - nC) == longint
>
> >
>
> > ? "Shortint?"
>
> > ? UsualType(nA) == shortint
>
> > ? "Longint?"
>
> > ? UsualType(nA) == longint
>
> >
>
> >     ? nB - nC
>
> >     ? nA
>
> > ? nA > ( nB - nC )
>
> > ? longint(nA) > ( nB - nC )
>
> >
>
> >          if longint(nA) > nB - nC
>
> >                  ? "748 is greater than (22 - 35)"
>
> >          else
>
> >                  ? "748 is not greater than (22 - 35). Oops!"
>
> >          endif
>
> >
>
> >          _Wait("")
>
> >
>
> >
>
> > return nil
>
> >
>
> >
>
> > Den m�ndagen den 27:e maj 2013 kl. 17:53:43 UTC+2 skrev 
> > kvste...@web.de:
>
> >> Hi out there,
>
> >>
>
> >>
>
> >>
>
> >> I'm getting strange results with simple calculations with shortints. 
> >> Consider this mini-test-app:
>
> >>
>
> >>
>
> >>
>
> >> 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("")
>
> >>
>
> >>
>
> >>
>
> >>
>
> >>
>
> >> Try it and tell me what happens here. When the three variables are 
> >> declared as longint, everything seems ok. But when they are shortints, 
> >> the result is obviously wrong. It seems to me that the results here are 
> >> well within the scope of a shortint, so what am I missing? (Using VO 
> >> 2.8 Sp2)
>
> >>
>
> >>
>
> >>
>
> >> Thanks for input
>
> >>
>
> >> Kay-Viktor
>
> >
>
>
>
>
>
> -- 
>
> Meinhard Schnoor-Matriciani
>
> Grafx Development Team 


--- news://freenews.netfront.net/ - complaints: news@netfront.net ---

Back to comp.lang.clipper.visual-objects | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

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

csiph-web