1. RE: Little incosistency in Euphoria 2.2

Hi,
this is not really an inconsistency problem, but still an annoyance.

The reason is that value() is interpreting "-45.6e-" as a number in written
in scientific notation. However it is a malformed number as it is expecting
an integer to follow the "e" character. For example "-45.6e3" is the
notation for -45.6 times 10 to the power 3, namely -45600. Also "-45.6e-3"
is the notation for -45.6 times 10 to the power -3, namely -0.0456.

-----------
cheers,
Derek Parnell

> -----Original Message-----
> From: rforno at tutopia.com [mailto:rforno at tutopia.com]
> Sent: Friday, 27 April 2001 6:20 AM
> To: EUforum
> Subject: Little incosistency in Euphoria 2.2
>
>
>
> While investigating the value() function and trying to mimic it, I
> discovered this little inconsistency:
> value("-45.6a-") gives {0,-45.6}
> but
> value("-45.6e-") gives {1,0}

new topic     » topic index » view message » categorize

2. RE: Little incosistency in Euphoria 2.2

On 27 Apr 2001, at 9:59, Derek Parnell wrote:

> Hi,
> this is not really an inconsistency problem, but still an annoyance.
> 
> The reason is that value() is interpreting "-45.6e-" as a number in written in
> scientific notation. However it is a malformed number as it is expecting an
> integer to follow the "e" character. For example "-45.6e3" is the notation for
> -45.6 times 10 to the power 3, namely -45600. Also "-45.6e-3" is the notation
> for -45.6 times 10 to the power -3, namely -0.0456.

Wouldn't this be a great reason to not use value()? So far, i haven't found a 
reason to use it anywhere. What would be a use for it that it cannot be 
replaced by another function, such as sprintf("%d",variable)?
 
Kat

> -----------
> cheers,
> Derek Parnell
> 
> > -----Original Message-----
> > From: rforno at tutopia.com [mailto:rforno at tutopia.com]
> > Sent: Friday, 27 April 2001 6:20 AM
> > To: EUforum
> > Subject: Little incosistency in Euphoria 2.2
> >
> >
> >
> > While investigating the value() function and trying to mimic it, I
> > discovered this little inconsistency:
> > value("-45.6a-") gives {0,-45.6}
> > but
> > value("-45.6e-") gives {1,0}
> 
> 
> 
> 
> 
>

new topic     » goto parent     » topic index » view message » categorize

3. RE: Little incosistency in Euphoria 2.2

> -----Original Message-----
> From: Kat [mailto:gertie at PELL.NET]
> Sent: Friday, 27 April 2001 2:18 PM
> To: EUforum
> Subject: RE: Little incosistency in Euphoria 2.2

> Wouldn't this be a great reason to not use value()? So far, i
> haven't found a reason to use it anywhere.

Hi Kat,
I agree with you. I never use value() because it has never suited any
purpose for me. I rolled my own routine to convert a string to a number (ie.
a sequence to an atom ). Its not perfect but it does the job.

> What would be a use for it that it cannot be
> replaced by another function, such as sprintf("%d",variable)?

Doesn't value() and sprintf() do the opposite of each other. value()
converts a sequence to an atom, and sprintf() converts an atom to a
sequence.

-----------
cheers,
Derek Parnell

new topic     » goto parent     » topic index » view message » categorize

4. RE: Little incosistency in Euphoria 2.2

On 27 Apr 2001, at 14:56, Derek Parnell wrote:


> 
> > -----Original Message-----
> > From: Kat [mailto:gertie at PELL.NET]
> > Sent: Friday, 27 April 2001 2:18 PM
> > To: EUforum
> > Subject: RE: Little incosistency in Euphoria 2.2
> 
> > Wouldn't this be a great reason to not use value()? So far, i
> > haven't found a reason to use it anywhere.
> 
> Hi Kat,
> I agree with you. I never use value() because it has never suited any
> purpose for me. I rolled my own routine to convert a string to a number (ie. a
> sequence to an atom ). Its not perfect but it does the job.
> 
> > What would be a use for it that it cannot be
> > replaced by another function, such as sprintf("%d",variable)?
> 
> Doesn't value() and sprintf() do the opposite of each other. value()
> converts a sequence to an atom, and sprintf() converts an atom to a
> sequence.

Oh,, right, oops. I guess the reason i never looked at it is that i don't store
a
number as a numeral, so it's an integer when i get it. Or i use an object type. 
It's easier, for me, to not make the integer(number) a sequence(numeral) till 
it's printed.

Kat

new topic     » goto parent     » topic index » view message » categorize

5. RE: Little incosistency in Euphoria 2.2

This is a multi-part message in MIME format.

------=_NextPart_000_0033_01C0CF58.31D83AE0
	charset="iso-8859-1"

Of course, but it is still an inconsistency.
  ----- Original Message -----=20
  From: daryl_vdb at HOTMAIL.COM=20
  To: EUforum=20
  Sent: Thursday, April 26, 2001 10:39 PM
  Subject: Re: Little incosistency in Euphoria 2.2



=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
Unbelievable: Unlimited Sales Leads Only $9.95 a Month
GoLeads is the best site for sales leads. Unlimited Access!
Includes Contact Names, Employee Size and Industry Headings.
  I think this is because value() thinks you were going to enter a =
number with a power of ten. eg
  =20
  value("45.6e2")
  =20
  should return 4560. =20
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
"So many interesting emails. So little time to read them.
Thanks to myTopica, I can find what I want, when I want it."
So can you.
=3D=3D^=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=

=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D


------=_NextPart_000_0033_01C0CF58.31D83AE0
Content-Type: text/html;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META content=3D"text/html; charset=3Diso-8859-1" =
http-equiv=3DContent-Type>
<META content=3D"MSHTML 5.00.2314.1000" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT face=3DArial size=3D2>Of course, but it is still an=20
inconsistency.</FONT></DIV>
<BLOCKQUOTE=20
style=3D"BORDER-LEFT: #000000 2px solid; MARGIN-LEFT: 5px; MARGIN-RIGHT: =
0px; PADDING-LEFT: 5px; PADDING-RIGHT: 0px">
  <DIV style=3D"FONT: 10pt arial">----- Original Message ----- </DIV>
  <DIV=20
  style=3D"BACKGROUND: #e4e4e4; FONT: 10pt arial; font-color: =
black"><B>From:</B>=20
  <A href=3D"mailto:daryl_vdb at HOTMAIL.COM"=20
  title=3Ddaryl_vdb at HOTMAIL.COM>daryl_vdb at HOTMAIL.COM</A> </DIV>
  <DIV style=3D"FONT: 10pt arial"><B>To:</B> <A =
href=3D"mailto:EUforum at topica.com"=20
  title=3DEUforum at topica.com>EUforum</A> </DIV>
  <DIV style=3D"FONT: 10pt arial"><B>Sent:</B> Thursday, April 26, 2001 =
10:39=20
  PM</DIV>
  <DIV style=3D"FONT: 10pt arial"><B>Subject:</B> Re: Little =
incosistency in=20
  Euphoria 2.2</DIV>
</PRE><PRE>=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
Unbelievable: Unlimited Sales Leads Only $9.95 a Month
GoLeads is the best site for sales leads. Unlimited Access!
Includes Contact Names, Employee Size and Industry Headings.
<A =
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D</PRE>
  <DIV><FONT face=3DArial size=3D2>I think this is because value() =
thinks you were=20
  going to enter a number with a power of ten. eg</FONT></DIV>
  <DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
  <DIV><FONT face=3DArial size=3D2>value("45.6e2")</FONT></DIV>
  <DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
  <DIV><FONT face=3DArial size=3D2>should return 4560.&nbsp; =
</FONT></DIV><PRE>=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D
"So many interesting emails. So little time to read them.
Thanks to myTopica, I can find what I want, when I want it."
So can you.
<A =
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D</PRE><PRE>=3D=
This email was sent to: rforno at tutopia.com

<A =
=3D=3D^=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=

------=_NextPart_000_0033_01C0CF58.31D83AE0--

new topic     » goto parent     » topic index » view message » categorize

6. RE: Little incosistency in Euphoria 2.2

Not really. The other post (it was also mine) said that value() would be
more useful if it also returned an index to the point it stopped, because in
this way the user can continue to recover data easily from the string.
----- Original Message -----
From: Ted Fines <fines at macalester.edu>
Subject: Re: Little incosistency in Euphoria 2.2


>
>
> Hmmm... Maybe I'm missing the point (likely, my wife says :)), but isn't
> this post regarding the value() function similar to the last one
> questioning how well value() worked? Similar in that they both feed
value()
> some kind of bad data?
>
> Garbage in -> Garbage out.  Maybe we're overloading value() and expecting
> too much?  If so, shouldn't we just write a different, more robust
> function?  I mean, how well does gets(fn) handle a bad sector on a hard
> disk?  Should we expect it to be able to handle ANY input we throw at it?
>
> The 'we' isn't the royal we...It's the Euphoria clan 'we'.   I'm including
> myself as I use the function too...
>
> --Ted
>
> --On Thursday, April 26, 2001 05:20:12 PM -0300 rforno at tutopia.com wrote:
>
> >
> >
> > While investigating the value() function and trying to mimic it, I
> > discovered this little inconsistency:
> > value("-45.6a-") gives {0,-45.6}
> > but
> > value("-45.6e-") gives {1,0}
> >
> >
> >
> >
> >
> >
>
>
>
>
>
>
>
>

new topic     » goto parent     » topic index » view message » categorize

7. RE: Little incosistency in Euphoria 2.2


new topic     » goto parent     » topic index » view message » categorize

8. RE: Little incosistency in Euphoria 2.2

This is a multi-part message in MIME format.

------=_NextPart_000_0057_01C0D00E.77E9BB60
	charset="iso-8859-1"

I think the problem is that we try to explain what value() "thinks" or is
doing, and not what it *should* do. For example, in case the argument is
78E6, it should of course return a valid result of 78 * 10 ^6, and in case
the argument is 78ER it should return also a valid result of 78 and not an
error. That is, once it got past the 'E' and finds that no valid exponent
follows, it should back up to the point it found 'E' and proceed as if it
got an 'A', to be consistent.
This is what I have attempted to do in the attached function. Comments in it
explain its workings. It reaches to a point previous to obtaining a numeric
value, and does not handle the case of a representation of an Euphoria
sequence, but only admits a character string. I have not thoroughly tested
it.
----- Original Message -----
From: Derek Parnell <ddparnell at bigpond.com>
To: EUforum <EUforum at topica.com>
Sent: Friday, April 27, 2001 10:06 PM
Subject: Re: Little incosistency in Euphoria 2.2


>
>
> ----- Original Message -----
> From: <rforno at tutopia.com>
> To: "EUforum" <EUforum at topica.com>
> Sent: Saturday, April 28, 2001 9:42 AM
> Subject: RE: Little incosistency in Euphoria 2.2
>
>
>
> > I cannot agree with you. If e- is bad, why a- is not?
>
> Because the letter 'e', when it immediately follows a series of digits, is
> regarded by value() to be a part of an embedded encoding of a number in
> scientific notation. If detected, it MUST be followed by another series of
> digits. If not, then value() believes you have a badly formatted number.
In
> the case of "a-", the 'a' character signals the END of a number and is not
> regarded as a part of the number's notation.
>
> However, I agree that this is not the best idea.
>
> Sorry for those who don't long posts but here is an attempt I made at
> writing a sequence-to-number conversion. I wanted to use the function
> seqtonumber() in an expression so it always returns an atom. To detected
> errors, I've had create another function that returns the error position.
> Finally, it does not support scientific notation (yet).
>
> ----------------------------
> integer vBase, vPeriod, vComma, vMoney
> sequence vLegalChars
> vBase = 10
> vPeriod = '.'
> vComma = ','
> vMoney = '$'
> vLegalChars = "0123456789abcdef-+.,"
>
> ---
> -- Sets the default number base to be used when converting strings to
> numbers.
> global function setnumberbase(integer pNewBase)
>     integer lOldBase
>
>     lOldBase = vBase
>
>     if pNewBase > 1 and pNewBase <= 16 then
>         vBase = pNewBase
>     end if
>
>     return lOldBase
> end function
>
> ---
> -- Sets the default punctuation characters.
> -- If any parameter is zero, then the corresponding punctuation symbol is
> not changed.
> -- All three punctuation symbols must be different from each other.
> -- Returns a sequence of three elements containing the current punctuation
> chars.
> --   1) The 'decimal place' character. Initially '.'
> --   2) The digit separator character. Initially ','
> --   3) The money symbol. Initially '$'
> global function setnumberpunct(integer pPeriod, integer pComma, integer
> pMoney)
>     sequence lOldValues
>
>     lOldValues = {vPeriod, vComma, vMoney}
<snip>

>
>
>
------=_NextPart_000_0057_01C0D00E.77E9BB60
Content-Type: application/octet-stream;
	name="Example.ex"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: attachment;
	filename="Example.ex"

function extract(sequence s)
    --Extracts a subsequence representing a number from an ASCII =
sequence
    --It returns a sequence with 3 elements:
    -- 1) An integer which reports if the 2nd element is a valid
    --  representation of a number or not (1 or 0 respectively)
    -- 2) A subsequence starting at the beginning of the argument which
    --  contains a valid or invalid representation of a number, =
including
    --  the (possible) termination character
    -- 3) The remaining part of the argument
    --For example, from "123E-P345 678" it will return
    -- {1,"123E","-P345 678"}
    integer i,  --Used as index into s
	    r  --Marks OK or error
    i =3D 1  --Initialize
    r =3D 0  --Set to FALSE
    while i <=3D length(s) and find(s[i], " \n\r\t") do  --Skip over =
whitespace
	i +=3D 1  --Bump index
    end while
    if i > length(s) then  --Test end of s
	return {r, s[1..i-1], {}}  --Returns 'error', result, remaining data
    elsif s[i] =3D '+' or s[i] =3D '-' then  --Check for sign
	i +=3D 1
    end if
    while i <=3D length(s) and find(s[i], "0123456789") do  --Whole part
	i +=3D 1
	r =3D 1  --Mark at least 1 mantissa digit
    end while
    if i <=3D length(s) and s[i] =3D '.' then  --Process period
	i +=3D 1
	while i <=3D length(s) and find(s[i], "0123456789") do  --Decimals
	    i +=3D 1
	    r =3D 1  --Mark at least 1 mantissa digit
	end while
    end if
    if i <=3D length(s) and (s[i] =3D 'e' or s[i] =3D 'E') then  =
--Exponent mark
	i +=3D 1
	if i > length(s) or 0 =3D find(s[i], "0123456789-+") then  --Unexpected
	    return {r, s[1..i-1], s[i..length(s)]}  --Return extracted sequence
	elsif s[i] =3D '-' or s[i] =3D '+' then  --Exponent sign
	    i +=3D 1
	end if
	if i > length(s) or 0 =3D find(s[i], "0123456789") then  --Unexpected
	    if s[i-1] =3D '-' or s[i-1] =3D '+' then  --Back up
		i -=3D 1
	    end if
	else
	    while i <=3D length(s) and find(s[i], "0123456789") do  --Exponent
		i +=3D 1
	    end while
	end if
    end if
    if i <=3D length(s) then
	i +=3D 1
    end if
    return {r, s[1..i-1], s[i..length(s)]}  --In any other case
end function


------=_NextPart_000_0057_01C0D00E.77E9BB60--

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu