## RE: [libertybasic] Digest Number 2188

Expand Messages
• Why does ----print val( 1/2 ) give you 1 any way to get it to get val of fractions?
Message 1 of 5 , Apr 5, 2006
Why does ----print val("1/2")
give you 1
any way to get it to get val of fractions?
• ... The following is from the help file of LB 4.03 VAL(stringExpression) Description: This function returns a numeric value for stringExpression if
Message 2 of 5 , Apr 5, 2006
--- In libertybasic@yahoogroups.com, "Rich & Rae" <richandrae@...> wrote:
>
> Why does ----print val("1/2")
> give you 1
> any way to get it to get val of fractions?
>

The following is from the help file of LB 4.03

VAL(stringExpression)

Description:
This function returns a numeric value for stringExpression if
stringExpression represents a valid numeric value or if it begins with
a valid numeric value. If not, then zero is returned.

Usage:

print 2 * val("3.14") Produces: 6.28

print val("hello") Produces: 0

print val("3 blind mice") Produces: 3

Since the '/' is not a number the 'val' expression is just retruning
the only number is can so you get '1' as the result
• The VAL() function looks at a string and sees numerical values up to the first non-numerical value. If you type in: PRINT VAL( 3/4 ) you will get 3, because
Message 3 of 5 , Apr 5, 2006
The VAL() function looks at a string and "sees" numerical values up to the first non-numerical value. If you type in:

PRINT VAL("3/4") you will get 3, because the / character is non-numerical.

I'm not sure I understand your question to "get rid of the fraction," but if you are looking for the decimal value you can use:

PRINT STR\$(1/2) or you can
PRINT 1/2 to get the same result.

Welopez
welopez@...

[Non-text portions of this message have been removed]
• ... Check help file for complete information on VAL() function. It s stopping at first non-numeric character. While you re there, check the EVAL() function.
Message 4 of 5 , Apr 5, 2006
Rich & Rae wrote:

>Why does ----print val("1/2")
>give you 1
>any way to get it to get val of fractions?
>
>
Check help file for complete information on VAL() function.
It's stopping at first non-numeric character.

While you're there, check the EVAL() function.
I'll bet EVAL("1/2") will give you what you want.

Regards,
Bill Beasley
• In a message dated 04/05/2006 9:27:18 AM Pacific Daylight Time, ... The number in the quotes is a string; the val() function turns a string into a numeral or
Message 5 of 5 , Apr 5, 2006
In a message dated 04/05/2006 9:27:18 AM Pacific Daylight Time,
richandrae@... writes:
>
> Why does ----print val("1/2")
> give you 1
> any way to get it to get val of fractions?
>
>

The number in the quotes is a string; the val() function turns a string into
a numeral or numeric value, but this ceases at the forward-slash, since the
forward slash is not a numeric value and cannot be turned from "/" into any sort
of number.

G C

[Non-text portions of this message have been removed]
Your message has been successfully submitted and would be delivered to recipients shortly.