[fpc-pascal] Sin function
Hi, according to docs/reference sin function should print 0.0 when Writeln (Sin(Pi):0:1); but, with fpc 2.4.0 and 2.4.2 (x86) I've get "-0.0", such a result is not entirely correct. This is a bug (in sin func.) or something wrong with the formatting ? best regards faber ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Progress indication while linking
Mark Morgan Lloyd wrote: Jonas Maebe wrote: The ld manual page lists some options you can use to reduce its memory usage: * --no-keep-memory (makes it re-read object symbol tables from time to time instead of keeping them in memory all the time) * --reduce-memory-overheads (small hash tables and slower but less memory-intensive link map generation algorithm) I scripted some builds over the afternoon with all combinations of those, running on a Linux SPARC system with 192Mb which I was hoping would be tight enough to be a good test. Unfortunately the timings on all four were very similar: --no-keep-memory (without --reduce-memory-overheads) gave about a minute's advantage out of about 18 minutes link time. I was hoping that --stats output might show something useful, but I think it gets swallowed. Vincent's suggestion of -t shows some useful info during the first part of the link, but in the sort of extreme case that I've currently got with Solaris I don't know at what point that would peter out. --stats does work. Running on a tighter system (128Mb) I get times for make all plus seconds in the linker: time make OPT='-k-t -k--stats' all real138m30.494s user26m43.840s sys 3m38.614s /usr/bin/ld: total time in link: 103.262453 lazarus /usr/bin/ld: total time in link: 32.394024 lazbuild /usr/bin/ld: total time in link: 34.706169 startlazarus Time to link all three binaries: 170 secs time make OPT='-k-t -k--stats -k--no-keep-memory' all real130m47.770s user28m1.017s sys 3m52.851s /usr/bin/ld: total time in link: 150.777423 lazarus /usr/bin/ld: total time in link: 44.086755 lazbuild /usr/bin/ld: total time in link: 50.603162 startlazarus Time to link all three binaries: 246 secs time make OPT='-k-t -k--stats -k--reduce-memory-overheads' all real125m16.758s user26m57.849s sys 3m28.657s /usr/bin/ld: total time in link: 93.757858 lazarus /usr/bin/ld: total time in link: 31.613976 lazbuild /usr/bin/ld: total time in link: 33.146071 startlazarus Time to link all three binaries: 159 secs time make OPT='-k-t -k--stats -k--reduce-memory-overheads -k--no-keep-memory' all real114m6.972s user27m51.780s sys 3m34.465s /usr/bin/ld: total time in link: 142.376898 lazarus /usr/bin/ld: total time in link: 43.362710 lazbuild /usr/bin/ld: total time in link: 49.955122 startlazarus Time to link all three binaries: 235 secs That appears to show a correlation between "user time" and the time the linker thinks its linking the big binaries, suggesting that the latter is got from process accounting rather than simple wallclock. The thing that really matters is the wallclock time, where performance on a tight system can be improved slightly by feeding options to ld. I've not tried this on a very tight system, i.e. 32Mb RAM since runtime for the four tests would be around a month. In all cases ld reports that linking the lazarus binary requires >200Mb working store, while the others require 120-150Mb. I think that explains why differences in timing start to stand out once there's less than 128Mb physical RAM. I don't know whether there's a significant downside to using these options on a large system, there might be if disc storage was comparatively slow. The thing that would probably make the most difference would be running in single user mode without any background daemons, but that's probably not possible unless logged in via a console connection. -- Mark Morgan Lloyd markMLl .AT. telemetry.co .DOT. uk [Opinions above are the author's, not those of his employers or colleagues] ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
[fpc-pascal] Sin function
faber wrote: Hi, according to docs/reference sin function should print 0.0 when Writeln (Sin(Pi):0:1); but, with fpc 2.4.0 and 2.4.2 (x86) I've get "-0.0", such a result is not entirely correct. This is a bug (in sin func.) or something wrong with the formatting ? best regards faber If I were you I would print it with more digits so you see if there is any significant difference at all. /Ingemar ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Sin function
> If I were you I would print it with more digits so you see if there is any > significant difference at all. ok I understand, I was suggested by http://www.freepascal.org/docs-html/rtl/system/sin.html where it is given score 0.0 for Writeln (Sin(Pi):0:1); best regards faber ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Sin function
Hi Ingemar 0.0 and -0.0 is the same number ;) it's just a quirk of the IEEE floating point format, that there exists a positiv and negative zero (because they use a sign bit). -Ivo Am 29.12.2010 12:17, schrieb Ingemar Ragnemalm: faber wrote: Hi, according to docs/reference sin function should print 0.0 when Writeln (Sin(Pi):0:1); but, with fpc 2.4.0 and 2.4.2 (x86) I've get "-0.0", such a result is not entirely correct. This is a bug (in sin func.) or something wrong with the formatting ? best regards faber If I were you I would print it with more digits so you see if there is any significant difference at all. /Ingemar ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Sin function
faber wrote: If I were you I would print it with more digits so you see if there is any significant difference at all. ok I understand, I was suggested by http://www.freepascal.org/docs-html/rtl/system/sin.html where it is given score 0.0 for Writeln (Sin(Pi):0:1); Transcendentals are a can of worms. Without and with formatting respectively, ARM, PowerPC, SPARC: 1.22464706384516E-016 0.0 x86 (P-III): -5.4210108624275222E-0020 -0.0 All FPC 2.4.2 on Linux. The result /should/ be zero, and x86- which I presume is what you're running- is nearer zero than the others :-) There are lots of issues here, including the number of bits used internally by the floating point hardware and whether it knows Pi to this degree of precision. Also it might depend on optimisation level etc. -- Mark Morgan Lloyd markMLl .AT. telemetry.co .DOT. uk [Opinions above are the author's, not those of his employers or colleagues] ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
[fpc-pascal] commutative operators
suppose I define an operator: operator + (a: one_type; b: another_type) : one_type; Is there any way to specify that it should be "commutative", so I don't have to additionally define the reverse: operator + (a: another_type; b: one_type) : one_type; Thanks ~David. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] commutative operators
2010/12/29 David Emerson : > suppose I define an operator: > > operator + (a: one_type; b: another_type) : one_type; > > Is there any way to specify that it should be "commutative", so I don't have > to > additionally define the reverse: > > operator + (a: another_type; b: one_type) : one_type; IIRC you don't have to. -- bflm freepascal-bits.blogspot.com ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] commutative operators
On Wed 29 Dec 2010, Honza wrote: > 2010/12/29 David Emerson : > > suppose I define an operator: > > > > operator + (a: one_type; b: another_type) : one_type; > > > > Is there any way to specify that it should be "commutative", so I don't > > have to > > additionally define the reverse: > > > > operator + (a: another_type; b: one_type) : one_type; > IIRC you don't have to. well... I do have to. I get "can't determine which overloaded function to call" because I have a lot of similar-looking functions and := operators it's not such a big deal, really. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] commutative operators
I think you need to make sure that `a' and `b' are in the same algebraic system before making the commutativity of the operator meaningful. Maybe you can merge `one_type' with `another_type' into a common type, or cast one to the other? - Original Message - Subject: [fpc-pascal] commutative operators From: David Emerson To: FPC-Pascal users discussions Time: Wed, 29 Dec 2010 10:38:14 -0800 MUA: KMail/1.9.9 > suppose I define an operator: > > operator + (a: one_type; b: another_type) : one_type; > > Is there any way to specify that it should be "commutative", so I don't have > to > additionally define the reverse: > > operator + (a: another_type; b: one_type) : one_type; > > Thanks > ~David. > > ___ > fpc-pascal maillist - fpc-pascal@lists.freepascal.org > http://lists.freepascal.org/mailman/listinfo/fpc-pascal -- Best Regards, J.-c. Chu ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] commutative operators
2010/12/29 David Emerson : > On Wed 29 Dec 2010, Honza wrote: >> IIRC you don't have to. > > well... I do have to. I get "can't determine which overloaded function to > call" > because I have a lot of similar-looking functions and := operators You're right, I verified it just now. I didn't remembered it correctly. FYI, bellow is the verification example used, later modified to compile successfully with trunk FPC. Introduction of the ':=' operators for T1 and T2 enabled the '+' operator commutativity. program project1; {$mode objfpc}{$H+} type T1 = record Dummy: Boolean; Value: Integer; end; T2 = record Dummy: String; Value: Integer; end; operator +(A: T1; B: T2): Integer; begin Result := A.Value + B.Value; end; operator :=(X: T1): T2; begin Result.Value := X.Value end; operator :=(X: T2): T1; begin Result.Value := X.Value end; var V1: T1; V2: T2; begin V1.Value := 2; V2.Value := 3; Writeln(V1 + V2, ' ', V2 + V1); end. -- bflm freepascal-bits.blogspot.com ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal