Forum > Unix

Currency compare different between 2.6.4 and 3.0.0 on Raspian

(1/2) > >>


I had an issue with a comparison of two currency values after upgrading from fpc 2.6.4 to 3.0.0. I had a look around but couldn't find anything about it. It could be related to how I'm using Abs() but I thought I'd post it here in case it really is a bug.

Here's my code:

--- Code: Pascal  window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---program quicktest;{$MODE OBJFPC}{$H+}uses    classes, sysutils, baseunix, crt;var    a: currency;    b: currency;begin    a := -6;    b := 9.6;    if b < Abs(a) then         writeln('this is madness!')     else         writeln('sanity prevails.');    // bonus round    writeln(IntToStr(Length('¥')));    writeln(IntToStr(Length('$')));end. 
When I compile that on fpc 2.6.4 it works and sanity prevails. When I compile it on fpc 3.0.0 there is madness. I have 2.6.4 on Raspbian Jessie and 3.0.0 on Raspbian Stretch but when I copy the 2.6.4 executable over to Stretch it works.

Also I noticed that the Yen symbol has a length of 2 while Dollar is only 1. This happens in 2.6.4 and 3.0.0.

Maybe all these are fixed in 3.0.4, I am investigating how to install that now. If not then I'll flip back to the 2.6.4 environment.


I can't help you regarding the problem with abs() but about this:

--- Quote from: kristakis on August 23, 2018, 04:45:17 am ---Also I noticed that the Yen symbol has a length of 2 while Dollar is only 1. This happens in 2.6.4 and 3.0.0.

--- End quote ---

that's most probably because your source is UTF-8. Unicode places the $ in the ASCII group (Ux32..Ux126), while the yen symbol (as all other monetary symbols) is in a higher code group which means UTF-8 needs more than one byte to code it.

Remember than Length() returns the lenght in bytes of its argument.

Incidentally ... FPC 3.0.0 is (relatively) old; lots of fixes were done up to the latest stable version 3.0.4 --- and even more up to 3.2.0 which is coming Really Soon(tm).


I copied/pasted your code and tested on FPC 3.0.4 Linux, I got correct result: "sanity prevails."

Works here too with 3.0.4

@lucamar Thanks for the info, I had the suspicion just after submitting that it might be a unicode thing.

@all Good to hear it's been fixed. I'll need to work on getting 3.0.4 installed on the Pi.



[0] Message Index

[#] Next page

Go to full version