#1 2009-08-13 12:09

SafetyCar
Senior Member
Registered: 2008-04-28
Posts: 446
Website

Floating point types (Pascal Script)

I'm trying to do some operations with pascal, but integers were limiting my attempts. I tryed to use extended type but I get lot's of "type mismatch error"

I just want to do the operations and later insert it to the FileName

I searched in the wiki but there are only the types .

Some help?


If this software has helped you, consider getting your pro version. :)

Offline

#2 2009-08-13 12:58

krtek
Senior Member
From: Łódź (Poland)
Registered: 2008-02-21
Posts: 262

Re: Floating point types (Pascal Script)

Give the code example, SafetyCar.
For now I might only suppose that you are trying either to use IntToStr or StrToInt functions with extended type.

If you are not using negative values you may try Cardinal type. It's about twice as big as Integer...

If you're stuck with extended type (although I can't imagine how it can be better for integer type operations) you may find
FloatToStr(Value : Extended), and StrToFloat(const S: string) functions handful...
There are also FloatToStr(Value: Extended; const FormatSettings: TFormatSettings) and FloatToStrF(Value: Extended; Format: TFloatFormat; Precision, Digits: Integer) functions that allow to specify format of the string, but I haven't checked if they work in PascalScript.

Last edited by krtek (2009-08-13 12:59)


Regular Expressions are not as hard to understand as you may think. Check ReNamer's manual or nice Regular Expressions tutorial for more info and start to use full power of applications that use them (like ReNamer, Mp3Tag and so on).

Offline

#3 2009-08-13 16:12

prologician
Member
Registered: 2009-01-30
Posts: 84

Re: Floating point types (Pascal Script)

Well, a quick look on Delphi Basics gave a short code snippet.... it seems like this behaves properly (I modified it a bit, as you can tell, but the variable names are largely the same...).

var
  account1, account2: Extended;
begin
  account2 := 3.14159265;
  account1 := account2 * 4.0/3.0;

  showmessage('Account2 = '+FloatToStr(account1));
end.

I'm going to venture that krtek guessed correctly on this one, since the "extended" type does seem to behave properly....

Offline

#4 2009-08-13 20:14

SafetyCar
Senior Member
Registered: 2008-04-28
Posts: 446
Website

Re: Floating point types (Pascal Script)

Ok, thats exactly what I needed to know, just didn't know about the existence of StrToFloat and FloatToStr.
(It's not on the help file, and not on the wiki roll)

Thanks big_smile

Last edited by SafetyCar (2009-08-13 20:14)


If this software has helped you, consider getting your pro version. :)

Offline

Board footer

Powered by FluxBB