Recent

Author Topic: Currency compare different between 2.6.4 and 3.0.0 on Raspian  (Read 6964 times)

kristakis

  • Newbie
  • Posts: 5
Currency compare different between 2.6.4 and 3.0.0 on Raspian
« on: August 23, 2018, 04:45:17 am »
Hi,

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  [Select][+][-]
  1. program quicktest;
  2. {$MODE OBJFPC}{$H+}
  3. uses
  4.     classes, sysutils, baseunix, crt;
  5. var
  6.     a: currency;
  7.     b: currency;
  8. begin
  9.     a := -6;
  10.     b := 9.6;
  11.     if b < Abs(a) then
  12.         writeln('this is madness!')
  13.     else
  14.         writeln('sanity prevails.');
  15.     // bonus round
  16.     writeln(IntToStr(Length('¥')));
  17.     writeln(IntToStr(Length('$')));
  18. end.
  19.  

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.

thanks.
kris

Things I hate:
1. Forum signatures
2. Irony
3. Lists

lucamar

  • Hero Member
  • *****
  • Posts: 4219
Re: Currency compare different between 2.6.4 and 3.0.0 on Raspian
« Reply #1 on: August 23, 2018, 05:24:14 am »
I can't help you regarding the problem with abs() but about this:

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.

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).
« Last Edit: August 23, 2018, 05:31:54 am by lucamar »
Turbo Pascal 3 CP/M - Amstrad PCW 8256 (512 KB !!!) :P
Lazarus/FPC 2.0.8/3.0.4 & 2.0.12/3.2.0 - 32/64 bits on:
(K|L|X)Ubuntu 12..18, Windows XP, 7, 10 and various DOSes.

Handoko

  • Hero Member
  • *****
  • Posts: 5130
  • My goal: build my own game engine using Lazarus
Re: Currency compare different between 2.6.4 and 3.0.0 on Raspian
« Reply #2 on: August 23, 2018, 05:29:14 am »
@kristakis

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

balazsszekely

  • Guest
Re: Currency compare different between 2.6.4 and 3.0.0 on Raspian
« Reply #3 on: August 23, 2018, 06:16:27 am »
Works here too with 3.0.4

kristakis

  • Newbie
  • Posts: 5
Re: Currency compare different between 2.6.4 and 3.0.0 on Raspian
« Reply #4 on: August 23, 2018, 07:01:23 am »
@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.

thanks,
kris
Things I hate:
1. Forum signatures
2. Irony
3. Lists

Thaddy

  • Hero Member
  • *****
  • Posts: 14197
  • Probably until I exterminate Putin.
Re: Currency compare different between 2.6.4 and 3.0.0 on Raspian
« Reply #5 on: August 23, 2018, 03:27:47 pm »

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.

thanks.
kris
3.0.4 is in stretch-backports
simply add that to /etc/apt/sources.list and use sudo apt-get -t fpc to install (must use -t parameter)
Specialize a type, not a var.

valdir.marcos

  • Hero Member
  • *****
  • Posts: 1106
Re: Currency compare different between 2.6.4 and 3.0.0 on Raspian
« Reply #6 on: August 23, 2018, 06:34:13 pm »
3.0.4 is in stretch-backports
simply add that to /etc/apt/sources.list and use sudo apt-get -t fpc to install (must use -t parameter)
The complete command is:
sudo apt-get -t stretch-backports fpc

But not so simply, you need to set Apt-Pinning:
Apt-Pinning for Beginners
https://jaqque.sbih.org/kplug/apt-pinning.html

Thaddy

  • Hero Member
  • *****
  • Posts: 14197
  • Probably until I exterminate Putin.
Re: Currency compare different between 2.6.4 and 3.0.0 on Raspian
« Reply #7 on: August 23, 2018, 09:12:36 pm »
But not so simply, you need to set Apt-Pinning:
Apt-Pinning for Beginners
https://jaqque.sbih.org/kplug/apt-pinning.html
I didn't use apt-pinning here. It was not necessary. It's backports, not unstable.
« Last Edit: August 23, 2018, 09:14:44 pm by Thaddy »
Specialize a type, not a var.

 

TinyPortal © 2005-2018