Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.forth > #34579
| From | anton@mips.complang.tuwien.ac.at (Anton Ertl) |
|---|---|
| Newsgroups | comp.lang.forth |
| Subject | Re: Why I like Forth |
| Date | 2014-11-23 15:28 +0000 |
| Organization | Institut fuer Computersprachen, Technische Universitaet Wien |
| Message-ID | <2014Nov23.162843@mips.complang.tuwien.ac.at> (permalink) |
| References | <87d988fc-26c2-492c-8e51-f0ede5758a69@googlegroups.com> <2014Nov23.142910@mips.complang.tuwien.ac.at> <d29afd9a-e5c0-41ff-bea3-f4cce9f0359c@googlegroups.com> |
mhx@iae.nl writes:
>On Sunday, November 23, 2014 2:39:09 PM UTC+1, Anton Ertl wrote:
>> mhx@iae.nl writes:
>> >========================================
>> >Scilab 5.5.0 (Apr 11 2014, 12:13:09)
>> >
>> >-->abs(int8(-128))
>> > ans =
>> >
>> > -128
>[..]
>> And your point is?
>
>On MATLAB R2014a:
>
>>> abs(int8(-128))
>ans =
> 127
>
>I do understand this result and that of C and all those Forths, but not Scilab's (it seems earlier MATLABs also say -128).
My guess for the -128 result is that abs is an int8->int8 function
there, and the result corresponds to "-9223372036854775808 abs" on
64-bit signed integers. I.e., int8(-128) is $80, and the result of
abs(int8(-128)) is $80 as well, and that is output as -128.
The 127 result is more surprising to me. I guess it is coming from
saturation arithmetics, and it's surprising, because I rarely
encounter saturation arithmetics.
- anton
--
M. Anton Ertl http://www.complang.tuwien.ac.at/anton/home.html
comp.lang.forth FAQs: http://www.complang.tuwien.ac.at/forth/faq/toc.html
New standard: http://www.forth200x.org/forth200x.html
EuroForth 2014: http://www.euroforth.org/ef14/
Back to comp.lang.forth | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Why I like Forth mhx@iae.nl - 2014-11-23 02:45 -0800
Re: Why I like Forth anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2014-11-23 13:29 +0000
Re: Why I like Forth mhx@iae.nl - 2014-11-23 06:58 -0800
Re: Why I like Forth anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2014-11-23 15:28 +0000
Re: Why I like Forth Julian Fondren <julian.fondren@gmail.com> - 2014-11-23 09:55 -0800
Re: Why I like Forth "Rod Pemberton" <buzzoff@nonamewhichexists.cmm> - 2014-11-23 14:33 -0500
Re: Why I like Forth Julian Fondren <julian.fondren@gmail.com> - 2014-11-23 12:35 -0800
Re: Why I like Forth mhx@iae.nl - 2014-11-23 13:23 -0800
csiph-web