
Thanks: 0
Likes: 0
Dislikes: 0

Junior Member
Working with numbers ???
Helpme please !
When I execute this function:

Function Main
VALOR1 = "1.145,00"
VALOR2 = "1.134,45"
VALOR3 = VAL(VALOR1)
VALOR4 = VAL(VALOR2)
IF VALOR3 > VALOR4 THEN
DIF = VALOR3  VALOR4
MessageBox("", DIF, "ok")
ELSE
MessageBox ("", "Error", "ok")
ENDIF
End Function ; Main

It is showing the following value: 1.055e002, but it would have to show 10.55.
How I can decide this problem ?
Thanks.
Scorpion

Senior Member
Re: Working with numbers ???
Scorpion,
To give the answer of 10.55 your variable would need to be in the format
VALOR1 = "1145.00"
VALOR2 = "1134.45"
When you conver these to Values they convert as
VALOR3 = 1145.00
VALOR4 = 1134.45
When entered as
VALOR1 = "1.145,00"
VALOR2 = "1.134,45"
they convert as
VALOR3 = 1.145
VALOR4 = 1.13445
To see what happens insert this before the If statement.
MessageBox("", VALOR3)
MessageBox("", VALOR4)
This will show what your variable have been converted to.
You may need to make use of the ReplaceStr() command to reformat your variables.
Hope this helps

Junior Member
Re: Working with numbers ???
Gevans,
I tried to use this function:

Function Main
V_CAS_ANNET = 1180.05
V_CAS_COB = 1180.03
VALOR5 = V_CAS_ANNET
VALOR6 = V_CAS_COB
IF VALOR5 > VALOR6 THEN
DIF_CASCO = VALOR5  VALOR6
ELSEIF VALOR5 < VALOR6 THEN
DIF_CASCO = VALOR6  VALOR5
ENDIF
MessageBox "", DIF_CASCO, "ok"
End Function ; Main

It is showing the following value:
1.9999999999982e002, but it would have to show 0.02.
How I can decide this problem ?
Thanks.
Scorpion

Senior Member
Re: Working with numbers ???
Scorpion,
This appears to be the way QARun handles numbers less than 1.
I must admit I haven't come across this before, I've always worked in integers.
However, having given it some thought and investigation, try this.
Select the Euro Convert Currency from Options and ensure that Britain GBP is set to 1.
Then try
DIF_CASCO = (VALOR5)  (VALOR6)
DIF_CASCO = ConvertCurrency ("GBP" , DIF_CASCO , "GBP" )
See if this works.
Darrel,
If you read this can you suggest anything else please.
Regards

Senior Member
Re: Working with numbers ???
I don't know if there is a system setting in Windows to handle this or not.
Did you try tech support?
One brute force method to try, and I don't know if this will work or not.
Multiply the original numbers by a power of 10 sufficient to get rid of all decimals.
Then do the math.
When the math is done, divide the result by the power of 10 you originally used.
Let us know what happens.

Senior Member
Re: Working with numbers ???
Originally posted by Darrel Damon:
One brute force method to try, and I don't know if this will work or not.
Multiply the original numbers by a power of 10 sufficient to get rid of all decimals.
Then do the math.
When the math is done, divide the result by the power of 10 you originally used.
<font size="2" face="Verdana, Arial, Helvetica">Darrel,
Thought of this first when I found the same thing happened on my installation. It only happens with figures less than 1
Tried multiplying by 100 to get rid of decimals but when you divide the result it comes back as 1.9999999999982e002.
Don't think that the WIndows settings has an effect on this as all my other progs work ok with decimals.
I hoped you might have some ideas as I have now reached the limit of my QARun knowledge. [img]images/icons/frown.gif[/img] [img]images/icons/frown.gif[/img]
Thanks & Regards

Senior Member
Re: Working with numbers ???
Nope. no clue. I cannot replicate this behavior. Sounds like time for a call to tech support.

Senior Member
Re: Working with numbers ???
If you're using the exact values you reference above... try removing the quotes.
VALOR1 = "1.145,00"
VALOR2 = "1.134,45"
You want to compare two values, not two strings. Once you try to use QARun to convert a string to a number by passing it through a numeric function... all sorts of bad things can happen.
QARun tries to figure out what you want to do and then tries to do the conversion for you. Most times in an incorrect fashion.
There may also be an issue with your nonAmerican formatting of the numbers. Swapping the commmas and decimal points... not sure if that will affect the VAL() function.

Senior Member
Re: Working with numbers ???
Broop,
In the second example that Scorpion gives there are no quotes in the variables.
I've tried the script with values of 1180.05 and 1180.03 and I get the same result as Scorpion.
This problem only seems to happen if the result is <1.0
I agree that the first problem reported by Scorpion in this post was a combination of the variables being input in quotes and the formatting of the numbers themselves.
Regards
Posting Permissions
 You may not post new threads
 You may not post replies
 You may not post attachments
 You may not edit your posts

Forum Rules
