xref: /PHP-8.2/ext/opcache/tests/jit/gh10271.phpt (revision 42eed7bb)
1--TEST--
2GH-10271: Incorrect arithmetic calculations when using JIT
3--INI--
4opcache.enable=1
5opcache.enable_cli=1
6opcache.file_update_protection=0
7opcache.jit_buffer_size=1M
8opcache.jit_hot_loop=1
9--FILE--
10<?php
11$tang['KSI']=-9.1751656444142E-5;
12$tang['ETA']=8.5076090069491E-5;
13
14$sol['X']['k']=-222.45470924306;
15$sol['X']['e']=-8.1787760034414;
16$sol['X'][1]=-0.020231298698539;
17
18$sol['Y']['k']=-14.400586941152;
19$sol['Y']['e']=392.95090925357;
20$sol['Y'][1]=-0.035664413413272;
21
22$sol['xc']=968;
23$sol['yc']=548;
24
25for( $p=0; $p<3; $p++ )
26{
27	print($p.': ');
28	Tangential2XY($tang,$sol);
29}
30
31function Tangential2XY(array $tang, array $sol) : array
32{
33	$x = $sol['X']['k']*$tang['KSI'] + $sol['X']['e']*$tang['ETA'] + $sol['X'][1];
34	$y = $sol['Y']['k']*$tang['KSI'] + $sol['Y']['e']*$tang['ETA'] + $sol['Y'][1];
35	printf("In;%.12f;%.12f;%.12f;%.12f;",$x,$y,$sol['xc'],$sol['yc']);
36	$x = $sol['xc']*($x+1);
37	$y = $sol['yc']*($y+1);
38	printf("Out;%.12f;%.12f\n",$x,$y);
39	if( $x<100 )
40		exit("Mamy to!\n");
41	return ['x'=>$x,'y'=>$y];
42}
43?>
44--EXPECT--
450: In;-0.000516528926;-0.000912408759;968.000000000000;548.000000000000;Out;967.500000000004;547.500000000009
461: In;-0.000516528926;-0.000912408759;968.000000000000;548.000000000000;Out;967.500000000004;547.500000000009
472: In;-0.000516528926;-0.000912408759;968.000000000000;548.000000000000;Out;967.500000000004;547.500000000009
48