val() with floating point < 1

Report any Hollywood bugs here
Post Reply
User avatar
lazi
Posts: 646
Joined: Thu Feb 24, 2011 11:08 pm

val() with floating point < 1

Post 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!
User avatar
lazi
Posts: 646
Joined: Thu Feb 24, 2011 11:08 pm

Re: val() with floating point < 1

Post 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      
User avatar
airsoftsoftwair
Posts: 5834
Joined: Fri Feb 12, 2010 2:33 pm
Location: Germany
Contact:

Re: val() with floating point < 1

Post by airsoftsoftwair »

Thanks, it's fixed now.
Post Reply