val() with floating point < 1

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

val() with floating point < 1

Post by lazi » Tue Oct 23, 2012 10:54 am

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: 407
Joined: Thu Feb 24, 2011 11:08 pm

Re: val() with floating point < 1

Post by lazi » Tue Oct 23, 2012 11:33 am

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: 3441
Joined: Fri Feb 12, 2010 2:33 pm
Location: Germany
Contact:

Re: val() with floating point < 1

Post by airsoftsoftwair » Sat Oct 27, 2012 12:08 pm

Thanks, it's fixed now.

Post Reply