You are not logged in.

Dear visitor, welcome to krpano.com Forum. If this is your first visit here, please read the Help. It explains in detail how this page works. To use all features of this page, you should consider registering. Please use the registration form, to register here or read more information about the registration process. If you are already registered, please login here.

jeromebg

Professional

  • "jeromebg" started this thread

Posts: 779

Location: Angers - France

Occupation: Photographer

  • Send private message

1

Tuesday, September 17th 2019, 1:09pm

Simple math operation bug ?

Hi,
Was just trying to increase or decrease a value with add and sub but the results are strange avec 2 operations :
exemple : http://360images.fr/calcstagescale/
xml : http://360images.fr/calcstagescale/pano.xml

Source code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
<krpano myvar="1">
	
<preview type="grid(cube,64,64,512,0x666666,0x222222,0x222222);" details="16" />

<style name="text_msg" type="text" bg="false" css="text-align:center; color:#ffffff; font-family:Arial; font-size:20px; font-weight:bold;"/>
	
<layer name="settings_menu" type="container" autoalpha="true" bg="true" bgalpha="1" bgcolor="0x000000" bgroundedge="15" align="center" width="300" height="100" keep="true">

		<layer name="minusscale" url="minus.png" onclick="sub(myvar,0.1);copy(layer[stagescalevalue].html,myvar)" align="left" x="20"/>
		<layer name="stagescalevalue" style="text_msg" align="center" html="calc:myvar" enabled="false"/>
		<layer name="plusscale" url="plus.png" onclick="add(myvar,0.1);copy(layer[stagescalevalue].html,myvar)" align="right" x="20"/>

</layer>
	
</krpano>


why is the value having a 0.10000001 change instead of 0.1 ?
Thx !

Tuur

Sage

Posts: 3,160

Location: Netherlands

Occupation: Krpano custom coding / Virtual Tours / Photography / Musician / Recording engineer

  • Send private message

2

Tuesday, September 17th 2019, 2:04pm

Hi,

strange.. seems a bug to me.
i also find it strange that bgroundedge gets egg shape sometimes.

https://www.virtualtuur.com/krpano/120/bugs/stagescale/

Tuur *thumbsup*
http://www.virtualtuur.com
Skype:studiotuur

jeromebg

Professional

  • "jeromebg" started this thread

Posts: 779

Location: Angers - France

Occupation: Photographer

  • Send private message

4

Tuesday, September 17th 2019, 9:14pm

Good to know ! First time hear about that ???
So with roundval it's working, but still pretty strange...

5

Wednesday, September 18th 2019, 9:25am

Hi,

that seems strange but is 'normal' for computer math ;-).

The links above are explaining that already very well and also another one:
http://blog.reverberate.org/2016/02/06/f…fied-part2.html

Or just google for '0.1 + 0.2' - that's a very common topic.

When you expect an exact number of decimal points always round to them.

E.g. instead of:

Source code

1
add(myvar,0.1);

try this:

Source code

1
calc(myvar, roundval(myvar + 0.1, 1) );


Best regards,
Klaus