Recent

Author Topic: Alias for Int64  (Read 9471 times)

kupferstecher

  • Hero Member
  • *****
  • Posts: 583
Re: Alias for Int64
« Reply #30 on: April 20, 2019, 10:34:32 pm »
It maybe wouldn't be a bad thing long term to make the int* types the fundamental compiler know types, and the old TP and OldDelphi names aliases
+1

The only obvious type for me is byte. All others I have to double check, because I'm never sure if I don't mix them up.

Tz

  • Jr. Member
  • **
  • Posts: 54
  • Tz with FPC Pen Cil
Re: Alias for Int64
« Reply #31 on: April 21, 2019, 06:49:12 am »
When redeclaring type with prefix T, when look the only type previously that has it, is TDateTime and TGuid.

So a whisper from java come to mine  :D you know that, but now my colorful lines fade away.
thank you for reminding me  :)

how about Timestamp and UUID, might useful for database specially postgres

Timestamp = TDateTime
UUID = TGuid

so it can be look like native.

my current type collection

Boolean, Boolean8, Boolean16, Boolean32, Boolean64,
NativeUInt, Cardinal, UInt8, UInt16, UInt32, UInt64,
NativeInt, Integer, Int8, Int16, Int32, Int64,
Single, Double, Extended, Currency, Pointer, 

for 64 bit using NativeUInt and NativeInt 
for 32 bit using Cardinal and Integer 
(or full and half size platform)

for Timestamp and UUID I have to experience first.

ByteBool, WordBool, LongBool, QWordBool in mean time I m not using it

ByteBool, WordBool, LongBool range 0 .. -1  unsigned but sign ?
QWordBool   -9223372036854775808 .. 9223372036854775807

Now for array,  back then still when I was newbie :)

string is array of char, is it?

[ 3 | a | b | c ]   
[ a | b | c | \0 ]

Hey you, yes you, count !  me: sir yes sir,  ....... one.
imagine if I said zero, I must have had 100 push up... or you should imagine his face  :D :D :D

array just start with zero and string with one ? (newbie).

back to array, naming arrayof for other seem ok, except for byte and char

ArrayOfChar String
ArrayOfByte TBytes

                  array          string
   Byte           Bytes          ByteString
   Word           Words          WordString        The computer read UTF16 as word ?
   Char           Chars          String
   WideChar       WideChars      WideString        ? diff only in windows use or not ref count
   AnsiChar       AnsiChars      AnsiString
   UnicodeChar    UnicodeChars   UnicodeString

eliminate first

   Byte           TBytes
   Char                          String
   AnsiChar                      AnsiString        UTF8 or just ASCII
   UnicodeChar                   UnicodeString     UTF16


How we can read or write Char seamlessly without knowing what kind encoding we use ?
(just use Char, see no Ansi and Unicode.)
while AnsiChar = Char, we cannot use Char as UnicodeChar, may be PChar ?

I would be happy if just use Byte, TBytes, Char, and String :)

While human use string, computer use bytes, the only thing bytes know is endian war.
or when to pass to network, for encoding in Base64.

   TBytes := BytesOf( EncodeBase64( String ) );
   String := DecodeBase64( TBytes.ToString );
   
@kupferstecher yes it's obvious.

Oh my, why just dont computer read a Char ....... ?


"it's not just a Char, it is zWick Char!"

Tz

  • Jr. Member
  • **
  • Posts: 54
  • Tz with FPC Pen Cil
Re: Alias for Int64
« Reply #32 on: April 21, 2019, 05:46:31 pm »
So sorry for HexStr( longint, cnt ),  I used cnt 16 for 32,  so its padded with zero string,  I change the code cast with Int64, now looks ok.

Now I think its done enough, for conclusion theres no need for other alias for Int64, in types.pp its already declare as  Largeint = int64;

Thank you all, for I learn a lot of it.

attach update.




marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 11383
  • FPC developer.
Re: Alias for Int64
« Reply #33 on: April 21, 2019, 11:42:58 pm »
Note that in Delphi starting with D2009, char=widechar.

So if you really want to stress 1-byte chars, best use "ansichar".

Tz

  • Jr. Member
  • **
  • Posts: 54
  • Tz with FPC Pen Cil
Re: Alias for Int64
« Reply #34 on: April 22, 2019, 03:15:40 am »
Two set naming   :D


8 16 32 64  vs    Byte Word Long QWord Short Small Long Large

Boolean           Boolean

Boolean8          ByteBool*
Boolean16         WordBool*
Boolean32         LongBool*
Boolean64         QWordBool*

UInt8             Byte*
UInt16            Word
UInt32            LongWord
UInt64            QWord
NativeUInt        NativeUInt
Cardinal          Cardinal

Int8              ShortInt
Int16             SmallInt
Int32             LongInt
Int64             LargeInt
NativeInt         NativeInt
Integer           Integer

Single            Single
Double            Double
Extended          Extended

Currency          Currency
DateTime          DateTime
Guid              Guid
Pointer           Pointer

Byte              Byte*
TBytes            TBytes

Char              Char
String            String

AnsiChar          AnsiChar
UnicodeChar       UnicodeChar

AnsiString        AnsiString
UnicodeString     UnicodeString


Tz

  • Jr. Member
  • **
  • Posts: 54
  • Tz with FPC Pen Cil
Re: Alias for Int64
« Reply #35 on: June 28, 2019, 06:02:48 pm »
question about extended

https://stackoverflow.com/questions/7120710/why-did-microsoft-abandon-long-double-data-type

considering bigdata, for sql data type decimal(38,4)

https://en.wikipedia.org/wiki/IEEE_754  2008 revision defines for 128bit

C# has decimal but only 28-29 significant digits ? (dont know why)
dont know about Java BigDecimal

is it time to move to 128 bit, Float128 = Decimal ? 

Remy Lebeau

  • Hero Member
  • *****
  • Posts: 1312
    • Lebeau Software
Re: Alias for Int64
« Reply #36 on: June 28, 2019, 08:39:11 pm »
Delphi has the int* types since afaik Delphi XE or so (2011,12?).

Since 2009, actually.
Remy Lebeau
Lebeau Software - Owner, Developer
Internet Direct (Indy) - Admin, Developer (Support forum)

Tz

  • Jr. Member
  • **
  • Posts: 54
  • Tz with FPC Pen Cil
Re: Alias for Int64
« Reply #37 on: June 28, 2019, 09:51:44 pm »
I dont have Delphi, so I could not check, but refer to http://docwiki.embarcadero.com/RADStudio/Rio/en/Simple_Types_(Delphi)

Extended 64-bit Intel Linux, while Size in bytes 16 (128bit),  in FPC which I test on Ubuntu and RedHat size is 10 bytes.

for Int128 and UInt128 not yet exists in .Net also, but is nice to have.

https://en.wikipedia.org/wiki/Floating-point_arithmetic

Float16 = Half
Float32 = Single = Decimal32
Float64 = Double = Decimal64
Float80 = Extended
Float128 = Quad = Decimal128

for sql like Postgresql we can declare decimal(38, 4), for financial use more close to money type.
(HugeMoney type ... my boss would be happy :) )

for scientific do not know, but I think more close to micro to nano  precission.  decimal(38,9)
but I chek CUDA for faster or paralel floating point process its only use just Single and Double

https://docs.nvidia.com/cuda/floating-point/index.html

also in MSSql have Datetime2 data type,
which Time range is 00:00:00 through 23:59:59.9999999 more precission than TDateTime

https://docs.microsoft.com/en-us/sql/t-sql/data-types/datetime2-transact-sql?view=sql-server-2017

for financial, time precission just enough to millisecond,
but for logging sample time for scientific is much more usefull as for statistic.






Tz

  • Jr. Member
  • **
  • Posts: 54
  • Tz with FPC Pen Cil

Tz

  • Jr. Member
  • **
  • Posts: 54
  • Tz with FPC Pen Cil
Re: Alias for Int64
« Reply #39 on: July 26, 2019, 04:23:12 pm »
using macro, it was cool.   :P,  last time I did not understand it well, so the code seems just not there

Size, MinValue, MaxValue

find some pattern for type conversion

var := type.Parse(string);

if type.TryParse(string, var) then WriteLn(var.ToString);



 

TinyPortal © 2005-2018