Hallo,
is there way to String2Float conversion?
String to Float or Real?
-
- Posts: 45
- Joined: 28 Jun 2013 03:22
Re: String to Float or Real?
You need to go to library management and install the library
- milos.vicentijevic
- Posts: 965
- Joined: 23 Apr 2013 08:09
Re: String to Float or Real?
Hello,
there is a way but unfortunately there is no such a library in mikroPascal, so you will have to write your own library for this purpose.
Best Regards,
Milos Vicentijevic
there is a way but unfortunately there is no such a library in mikroPascal, so you will have to write your own library for this purpose.
Best Regards,
Milos Vicentijevic
Re: String to Float or Real?
Hallo,
the old additional string library works with some modifiaktion.
It will be great, if Mikroe will put more such thinks in his library.
Because a User to user Version is LunaAvr this is Pascal like for free.
But I use Mikroe because i think there will be a company that do thhis thinks
For this library i have to modificate all str2LongInt to strtoint...is this the same?
Or what is longint or longword now?
the old additional string library works with some modifiaktion.
It will be great, if Mikroe will put more such thinks in his library.
Because a User to user Version is LunaAvr this is Pascal like for free.
But I use Mikroe because i think there will be a company that do thhis thinks
For this library i have to modificate all str2LongInt to strtoint...is this the same?
Or what is longint or longword now?
Code: Select all
function StrtoFloat(var data_str4 : string[17]) : real;
var txt10 : string[10];
lungime, lungime1 : byte;
pt1, pt2 : ^byte;
begin
result := 0.;
lungime := Str_Len(data_str4);
if (lungime = 0) or (lungime > 17) then exit;
lungime1 := Str_Chr(data_str4,'.');
if lungime1 = 0 then exit;
txt10 := '00000';
pt1 := @data_str4[lungime1];
pt1^ := 0;
pt1 := pt1 + 1;
pt2 := @txt10;
inc(lungime1);
while lungime1 < lungime do
begin
pt2^ := pt1^;
pt2 := pt2 + 1;
pt1 := pt1 + 1;
inc(lungime1);
end;
if data_str4[0] = '-' then result := real(StrtoInt(data_str4)) - real(StrtoWord(txt10))/100000.0
else result := real(StrtoInt(data_str4)) + real(StrtoWord(txt10))/100000.0;
end;
- milos.vicentijevic
- Posts: 965
- Joined: 23 Apr 2013 08:09
Re: String to Float or Real?
Hello,
longint is 32bit with scope -2147483648 .. 2147483647 . Instead of longword there is a dword. It is 32bit with scope 0 .. 4294967295.
Please, check Help Simple Types file for details.
Best Regards,
Milos Vicentijevic
longint is 32bit with scope -2147483648 .. 2147483647 . Instead of longword there is a dword. It is 32bit with scope 0 .. 4294967295.
Please, check Help Simple Types file for details.
Best Regards,
Milos Vicentijevic