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


Groups > comp.lang.forth > #25798

Re: well this code works and I had some guy say it doesn't

From rickman <gnuarm@gmail.com>
Newsgroups comp.lang.forth
Subject Re: well this code works and I had some guy say it doesn't
Date 2013-09-19 03:09 -0400
Organization A noiseless patient Spider
Message-ID <l1e7vl$6db$1@dont-email.me> (permalink)
References <d7f43d90-5ea4-47f4-b309-de6fbad1f677@googlegroups.com> <5e19d09b-027f-420a-a569-5123a16319e6@googlegroups.com>

Show all headers | View raw


On 9/19/2013 2:35 AM, VoidVolker wrote:
> четверг, 19 сентября 2013 г., 9:55:55 UTC+4 пользователь gavino_himself написал:
>> $ gforth
>> Gforth 0.7.2, Copyright (C) 1995-2008 Free Software Foundation, Inc.
>> Gforth comes with ABSOLUTELY NO WARRANTY; for details type `license'
>> Type `bye' to exit
>>
>> : stock-gain 100 * swap / 100 - cr . ." precent" cr ; redefined stock-gain   ok
>> 34 55 stock-gain
>> 61 precent
>>   ok
>>
>>
>> IN YOUR FUCKING FACE!!
>
> Yes, the code is work, but it's calculate not percents =) Look here:
>
> 30 100  stock-gain
> 233 precent
>
> 100 30 stock-gain .
> -70 precent
>
> Now, let's calculate real percents - the word */ exist for it:
>      : p% 100 SWAP */ CR . ." %" CR ;  ok
>      34 55 p%
>      61 %
>       ok
>
> Or:
>
>      : p%2 10000 SWAP */ CR S>D<# [CHAR] % HOLD # # [CHAR] . HOLD #S #>  TYPE CR ;
>      34 55 p%2
>      61.81%
>       ok
>
>      30 100 p%2
>      30.00%
>       ok
>
>      100 30 p%2
>      333.33%
>       ok

I think you don't understand what Gavino's code is doing.  It is 
calculating the percent gain or loss, not the simple percent ratio.  To 
get gain you take the ratio, subtract one, then multiply by 100.

/ 1.0 - 100.0 *  (floating point numbers, not literal forth)

That is why he subtracts 100, the same as subtracting the 1, but after 
multiplying by 100.

-- 

Rick

Back to comp.lang.forth | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

well this code works and I had some guy say it doesn't gavino_himself <visploveslisp@gmail.com> - 2013-09-18 22:55 -0700
  Re: well this code works and I had some guy say it doesn't gavino_himself <visploveslisp@gmail.com> - 2013-09-18 22:58 -0700
  Re: well this code works and I had some guy say it doesn't VoidVolker <voidvolker@gmail.com> - 2013-09-18 23:35 -0700
    Re: well this code works and I had some guy say it doesn't rickman <gnuarm@gmail.com> - 2013-09-19 03:09 -0400
      Re: well this code works and I had some guy say it doesn't gavino_himself <visploveslisp@gmail.com> - 2013-09-19 01:11 -0700
        Re: well this code works and I had some guy say it doesn't rickman <gnuarm@gmail.com> - 2013-09-19 04:32 -0400
          Re: well this code works and I had some guy say it doesn't Elizabeth D Rather <erather@forth.com> - 2013-09-19 14:15 -1000
            Re: well this code works and I had some guy say it doesn't "Ed" <invalid@invalid.com> - 2013-09-21 12:48 +1000
              Re: well this code works and I had some guy say it doesn't "Elizabeth D. Rather" <erather@forth.com> - 2013-09-20 17:52 -1000
                Re: well this code works and I had some guy say it doesn't rickman <gnuarm@gmail.com> - 2013-09-21 08:46 -0400
                Re: well this code works and I had some guy say it doesn't Doug Hoffman <glidedog@gmail.com> - 2013-09-21 10:40 -0400
                Re: well this code works and I had some guy say it doesn't rickman <gnuarm@gmail.com> - 2013-09-21 10:48 -0400
                Re: well this code works and I had some guy say it doesn't Doug Hoffman <glidedog@gmail.com> - 2013-09-21 18:12 -0400
                Re: well this code works and I had some guy say it doesn't albert@spenarnc.xs4all.nl (Albert van der Horst) - 2013-09-23 16:59 +0000
                Re: well this code works and I had some guy say it doesn't "WJ" <w_a_x_man@yahoo.com> - 2013-09-21 17:48 +0000
                Re: well this code works and I had some guy say it doesn't Doug Hoffman <glidedog@gmail.com> - 2013-09-21 19:34 -0400
                Re: well this code works and I had some guy say it doesn't "Ed" <invalid@invalid.com> - 2013-09-22 11:51 +1000
                Re: well this code works and I had some guy say it doesn't hughaguilar96@yahoo.com - 2013-09-21 21:09 -0700
                Re: well this code works and I had some guy say it doesn't "Rod Pemberton" <dont_use_email@nohavenotit.com> - 2013-09-21 13:09 -0400
                Re: well this code works and I had some guy say it doesn't "Elizabeth D. Rather" <erather@forth.com> - 2013-09-21 08:37 -1000
                Re: well this code works and I had some guy say it doesn't albert@spenarnc.xs4all.nl (Albert van der Horst) - 2013-09-23 17:26 +0000
          Re: well this code works and I had some guy say it doesn't the_gavino_himself <visphatesjava@gmail.com> - 2013-09-21 02:19 -0700
      Re: well this code works and I had some guy say it doesn't "WJ" <w_a_x_man@yahoo.com> - 2013-09-19 09:16 +0000
        Re: well this code works and I had some guy say it doesn't the_gavino_himself <visphatesjava@gmail.com> - 2013-09-20 23:08 -0700
          Re: well this code works and I had some guy say it doesn't rickman <gnuarm@gmail.com> - 2013-09-21 08:47 -0400
  Re: well this code works and I had some guy say it doesn't Spam@ControlQ.com - 2013-09-19 11:16 -0400
    Re: well this code works and I had some guy say it doesn't the_gavino_himself <visphatesjava@gmail.com> - 2013-09-20 23:07 -0700
  Re: well this code works and I had some guy say it doesn't "Rod Pemberton" <dont_use_email@nohavenotit.com> - 2013-09-20 04:37 -0400
    Re: well this code works and I had some guy say it doesn't "Elizabeth D. Rather" <erather@forth.com> - 2013-09-19 22:45 -1000
      Re: well this code works and I had some guy say it doesn't Howerd <howerdo@yahoo.co.uk> - 2013-09-20 01:49 -0700
        Re: well this code works and I had some guy say it doesn't the_gavino_himself <visphatesjava@gmail.com> - 2013-09-20 23:10 -0700
    Re: well this code works and I had some guy say it doesn't rickman <gnuarm@gmail.com> - 2013-09-20 08:19 -0400
      Re: well this code works and I had some guy say it doesn't the_gavino_himself <visphatesjava@gmail.com> - 2013-09-20 23:11 -0700
    Re: well this code works and I had some guy say it doesn't the_gavino_himself <visphatesjava@gmail.com> - 2013-09-20 23:09 -0700
    Re: well this code works and I had some guy say it doesn't Mark Wills <markrobertwills@yahoo.co.uk> - 2013-09-24 07:46 -0700

csiph-web