Page 1 of 1

val() with floating point < 1

Posted: Tue Oct 23, 2012 10:54 am
by lazi
Hi!

Just found that Val() doesn't give back correct result if the floaing point number starting with the decimal point.

Val(".1415") => 0
Val("0.1415") => 0.1415
Val("0"..".1415") => 0.1415

All calculators and programming languages that I know means the number is greater that 0 and smaller then 1 if it starts with a decimal point. I think Hollywood should behave just like others in this context. Don't you?

Bye!

Re: val() with floating point < 1

Posted: Tue Oct 23, 2012 11:33 am
by lazi
Here is a workaround:

Code: Select all

factory_val=Val
function Val(s)
    if LeftStr(s,1)="."
        s="0"..s
    elseif LeftStr(s,2)="-."
        s="-0"..s
    endif
    Return(factory_val(s))
endfunction      

Re: val() with floating point < 1

Posted: Sat Oct 27, 2012 12:08 pm
by airsoftsoftwair
Thanks, it's fixed now.