Expr and floating point numbers

Expr and floating point numbers

Post by Lekeas G » Fri, 24 May 2002 23:21:44



Hi All,

I am trying to use expr to do simple arithmetic; divide a floating point
number by an integer (I know there are bc and dc, was just curious about
that)...The outcome I get is expr: non-numeric argument. I tried quoting the
/ character but I am still getting the same result.

Is expr not accepting floating point numbers or am I doing something wrong
here?

--
George

 
 
 

Expr and floating point numbers

Post by Bill Marc » Sat, 25 May 2002 02:41:58


On Thu, 23 May 2002 15:21:44 +0100,

Quote:>Hi All,

>I am trying to use expr to do simple arithmetic; divide a floating point
>number by an integer (I know there are bc and dc, was just curious about
>that)...The outcome I get is expr: non-numeric argument. I tried quoting the
>/ character but I am still getting the same result.

>Is expr not accepting floating point numbers or am I doing something wrong
>here?

Expr doesn't do floating point.

 
 
 

Expr and floating point numbers

Post by David Thompso » Sat, 25 May 2002 02:57:53



Quote:> Hi All,

> I am trying to use expr to do simple arithmetic; divide a floating point
> number by an integer (I know there are bc and dc, was just curious about
> that)...The outcome I get is expr: non-numeric argument. I tried quoting
the
> / character but I am still getting the same result.

> Is expr not accepting floating point numbers or am I doing something wrong
> here?

Fyi, ksh93 supports floating point arithmetic directly.

--
David Thompson

 
 
 

Expr and floating point numbers

Post by Barry Margoli » Sat, 25 May 2002 02:58:53




>Is expr not accepting floating point numbers or am I doing something wrong
>here?

Have you RTFM?

     expr { +, - } expr
                    Addition  or  subtraction  of  integer-valued
                    arguments.

     expr { \*, /, % } expr
                    Multiplication, division, or remainder of the
                    integer-valued arguments.
                    ^^^^^^^^^^^^^^

--

Genuity, Woburn, MA
*** DON'T SEND TECHNICAL QUESTIONS DIRECTLY TO ME, post them to newsgroups.
Please DON'T copy followups to me -- I'll assume it wasn't posted to the group.

 
 
 

Expr and floating point numbers

Post by Lekeas G » Sat, 25 May 2002 22:51:43


Hi Barry,

My manual (bash on SunOS) reads:

ARG1 / ARG2

arithmetic quotient of ARG1 divided by ARG2...No mention about integer or
floating point numbers...

George


> Date: Thu, 23 May 2002 17:58:53 GMT

> Newsgroups: comp.unix.questions
> Subject: Re: Expr and floating point numbers



> >Is expr not accepting floating point numbers or am I doing something wrong
> >here?

> Have you RTFM?

>      expr { +, - } expr
>                     Addition  or  subtraction  of  integer-valued
>                     arguments.

>      expr { \*, /, % } expr
>                     Multiplication, division, or remainder of the
>                     integer-valued arguments.
>                     ^^^^^^^^^^^^^^

> --

> Genuity, Woburn, MA
> *** DON'T SEND TECHNICAL QUESTIONS DIRECTLY TO ME, post them to newsgroups.
> Please DON'T copy followups to me -- I'll assume it wasn't posted to the group.

 
 
 

Expr and floating point numbers

Post by David Thompso » Sun, 26 May 2002 00:59:44





> > >Is expr not accepting floating point numbers or am I doing something
wrong
> > >here?

> > Have you RTFM?

> >      expr { +, - } expr
> >                     Addition  or  subtraction  of  integer-valued
> >                     arguments.

> >      expr { \*, /, % } expr
> >                     Multiplication, division, or remainder of the
> >                     integer-valued arguments.

> My manual (bash on SunOS) reads:

> ARG1 / ARG2

> arithmetic quotient of ARG1 divided by ARG2...No mention about integer or
> floating point numbers...

Please don't top-post.  Insert your comments under those
of the person you're replying to, like I'm doing here.

Barry's snippets above are from 'man expr', he is pointing
out that your original OP regarding expr is answered by a
simple RTFM of expr's man page.

--
David Thompson

 
 
 

Expr and floating point numbers

Post by Chris F.A. Johnso » Sun, 26 May 2002 02:18:46






>> > >Is expr not accepting floating point numbers or am I doing something
> wrong
>> > >here?

>> > Have you RTFM?

>> >      expr { +, - } expr
>> >                     Addition  or  subtraction  of  integer-valued
>> >                     arguments.

>> >      expr { \*, /, % } expr
>> >                     Multiplication, division, or remainder of the
>> >                     integer-valued arguments.

>> My manual (bash on SunOS) reads:

>> ARG1 / ARG2

>> arithmetic quotient of ARG1 divided by ARG2...No mention about integer or
>> floating point numbers...

> Please don't top-post.  Insert your comments under those
> of the person you're replying to, like I'm doing here.

> Barry's snippets above are from 'man expr', he is pointing
> out that your original OP regarding expr is answered by a
> simple RTFM of expr's man page.

    Unfortunately, not all man pages are that explicit. In the GNU man
    page for expr, the word "integer" does not appear once.

--
    Chris F.A. Johnson                        http://cfaj.freeshell.org
    ===================================================================
    My code (if any) in this post is copyright 2002, Chris F.A. Johnson
    and may be copied under the terms of the GNU General Public License

 
 
 

Expr and floating point numbers

Post by David Thompso » Sun, 26 May 2002 02:57:20




> > Barry's snippets above are from 'man expr', he is pointing
> > out that your original OP regarding expr is answered by a
> > simple RTFM of expr's man page.

>     Unfortunately, not all man pages are that explicit. In the GNU man
>     page for expr, the word "integer" does not appear once.

What?  GNU man pages don't mention that?  ;)

Somehow that doesn't surprise me.  IMHO, GNU continues to do
a grave disservice by a lack of devotion to man pages.  It's
great that info pages are there, that's not my beef, I find
it a perpetual source of frustration that GNU man pages are
so information poor.  Ie, try 'man date' on GNU.

Chris, do you think other OS's lack this mention of integer
in the expr man page?  I mean, I think GNU is the exception
here.  Your thoughts?

Btw, OP said he was looking at 'man bash' on SunOS, which is
the wrong place to be looking for information about expr.

--
David Thompson

 
 
 

Expr and floating point numbers

Post by Chris F.A. Johnso » Mon, 27 May 2002 05:57:36





>> > Barry's snippets above are from 'man expr', he is pointing
>> > out that your original OP regarding expr is answered by a
>> > simple RTFM of expr's man page.

>>     Unfortunately, not all man pages are that explicit. In the GNU man
>>     page for expr, the word "integer" does not appear once.

> What?  GNU man pages don't mention that?  ;)

> Somehow that doesn't surprise me.  IMHO, GNU continues to do
> a grave disservice by a lack of devotion to man pages.  It's
> great that info pages are there, that's not my beef, I find
> it a perpetual source of frustration that GNU man pages are
> so information poor.  Ie, try 'man date' on GNU.

> Chris, do you think other OS's lack this mention of integer
> in the expr man page?  I mean, I think GNU is the exception
> here.  Your thoughts?

    All other man pages I've looked at (AT&T SVR3.2, SunOs, Solaris,
    FreeBSD, NetBSD), and the POSIX specs, refer to "integer-valued
    arguments".

Quote:> Btw, OP said he was looking at 'man bash' on SunOS, which is
> the wrong place to be looking for information about expr.

    He probably doesn't know about the "type" builtin command.

--
    Chris F.A. Johnson                        http://cfaj.freeshell.org
    ===================================================================
    My code (if any) in this post is copyright 2002, Chris F.A. Johnson
    and may be copied under the terms of the GNU General Public License