ASE Home Page Products Download Purchase Support About ASE
ChartDirector Support
Forum HomeForum Home   SearchSearch

Message ListMessage List     Post MessagePost Message

  Questions about using ChartDirector for C++ and ChartDirector for PHP in one program
Posted by Ning on Feb-07-2025 16:58
Attachments:
Hello Support,

We need to have both ChartDirector for C++ and ChartDirector for PHP in one program. There is one libchartdir.so  for ChartDirector for PHP, and there is another one libchartdir.so (the actual lib is libchartdir.so.7.0.0)  in ChartDirector for C++, and they are different.
Firstly, there differ in size.
Secondly, we tried to compare the libchartdir.so from ChartDirector for PHP and the libchartdir.so in ChartDirector for C++, there is slight difference (although not visually detectable). In the attachment is an example of difference when tried on cppdemo/anglepie.
Notes on the image:
from left to right: anglepie0.png generated using libchartdir.so in ChartDirector for C++, anglepie0.png using libchartdir.so in ChartDirector for PHP, difference.
The difference is calculated with imagemagick.

Questions:

1. What are the differences between the libchartdir.so in ChartDirector for PHP and the one in ChartDirector for C++?
2. Is it valid to use the libchartdir.so in ChartDirector for PHP in c++ code? Or vice versa? Or any other suggestions?

Thanks and best regards,
Ning
anglepie0-cpp-php-diff.png

  Re: Questions about using ChartDirector for C++ and ChartDirector for PHP in one program
Posted by Peter Kwan on Feb-08-2025 02:32
Hi Ning,

Yes, you can use the same libchartdir.so for both C++ and PHP.

The libchartdir.so can be different because sometimes we may patch the libchartdir.so, and the patch may only affect certain programming languages. In general, you can use the more updated one (based on the file date) for both C++ and PHP.

We tested ChartDirector using similar methods as yours - by comparing pixel by pixel to a reference image. We learn that modern computers are "practically non-deterministic", especially Intel CPUs. The same code can produce different results randomly. yet all of the results are considered as correct. So it is normal the images can be slightly different.

If you are interested to know why computers are "practically non-deterministic", the following is one possibility how this can happen:

- In IEEE 754 standard, double precision floating points is 64-bit.

- Intel CPU can handle 80 bit floating point.

- Consider the code x = b / c, there are two possibilities:
  (i) computer b / c in 64-bit mode, and store the result in x.
  (ii) computer b / c in 80-bit mode, and round the result to 64-bit and store in x.

The (i) and (ii) can produce different results, yet both are consider as correct. The method used depends on a flag set in the FPU. The job of the compiler is to generate the fastest code that produce the correct result. Since both are correct, the compiler may omit the code to set the flag. Thus the flag can be in an unknown state.

In practice, the result can depend on the operating environment, that is, weather the shared object is running under PHP, Perl, Python, C++ or other environments.

The effect on the image is that some pixels may change by a small amount, or the text may shift by 1 pixel. They are normally not noticeable.

Best Regards
Peter Kwan