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


Groups > comp.graphics.apps.gnuplot > #2852 > unrolled thread

Curiosity: Arithmetic operations and leading zeros

Started byj.strecha@gmail.com
First post2015-04-01 03:43 -0700
Last post2015-04-02 20:43 +0200
Articles 4 — 3 participants

Back to article view | Back to comp.graphics.apps.gnuplot


Contents

  Curiosity: Arithmetic operations and leading zeros j.strecha@gmail.com - 2015-04-01 03:43 -0700
    Re: Curiosity: Arithmetic operations and leading zeros Richard Owlett <rowlett@cloud85.net> - 2015-04-01 06:25 -0500
      Re: Curiosity: Arithmetic operations and leading zeros j.strecha@gmail.com - 2015-04-01 05:57 -0700
        Re: Curiosity: Arithmetic operations and leading zeros Karl <mail.kfr@gmx.net> - 2015-04-02 20:43 +0200

#2852 — Curiosity: Arithmetic operations and leading zeros

Fromj.strecha@gmail.com
Date2015-04-01 03:43 -0700
SubjectCuriosity: Arithmetic operations and leading zeros
Message-ID<b286ed07-4f0a-4fd2-bf03-dd3176de25f0@googlegroups.com>
Hi,

I recently discovered something curious about arithmetic operations in gnuplot:

> gnuplot> print 2*66
> 132
> gnuplot> print 2*066
> 108

(gnuplot 5.0 patchlevel rc2)

Apparently the multiplication behaves differently when leading zeros are present. Is this a bug, or a feature?

Regards,
JS

[toc] | [next] | [standalone]


#2853

FromRichard Owlett <rowlett@cloud85.net>
Date2015-04-01 06:25 -0500
Message-ID<D4WdnR9wePZdSIbInZ2dnUU7-UOdnZ2d@supernews.com>
In reply to#2852
j.strecha@gmail.com wrote:
> Hi,
>
> I recently discovered something curious about arithmetic operations in gnuplot:
>
>> gnuplot> print 2*66
>> 132
>> gnuplot> print 2*066
>> 108
>
> (gnuplot 5.0 patchlevel rc2)
>
> Apparently the multiplication behaves differently when leading zeros are present. Is this a bug, or a feature?
>
> Regards,
> JS
>

How does gnuplot handle input of octal numbers? {I don't have 
gnuplot on this machine to check.)

I notice that for your example that for example shown the answer 
is correct for octal input and defaulting to decimal on output.

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


#2854

Fromj.strecha@gmail.com
Date2015-04-01 05:57 -0700
Message-ID<e57120ff-2945-464a-a489-7e2961603a94@googlegroups.com>
In reply to#2853
Of course, you're right. I didn't check for octal numbers. However, this appears to be an undocumented feature.

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


#2859

FromKarl <mail.kfr@gmx.net>
Date2015-04-02 20:43 +0200
Message-ID<mfk2k5$qni$1@news.rz.uni-karlsruhe.de>
In reply to#2854
Am 01.04.2015 um 14:57 schrieb j.strecha@gmail.com:
> Of course, you're right. I didn't check for octal numbers. However, this appears to be an undocumented feature.
> 

You can also enter hex numbers by starting them with "0x", btw.

I've submitted a patch to the docs on this.

  Karl

[toc] | [prev] | [standalone]


Back to top | Article view | comp.graphics.apps.gnuplot


csiph-web