Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c++ > #70330

Re: What does the "L" mean

From boltar@nowhere.co.uk
Newsgroups comp.lang.c++
Subject Re: What does the "L" mean
Date 2019-12-07 11:57 +0000
Organization Aioe.org NNTP Server
Message-ID <qsg442$7mp$1@gioia.aioe.org> (permalink)
References <qs7npd$5jn$1@dont-email.me> <qs7o3e$5mt$1@news.albasani.net> <SxwGF.448286$Sw5.226652@fx21.am4>

Show all headers | View raw


On Fri, 6 Dec 2019 17:50:39 +0000
Bart <bc@freeuk.com> wrote:
>On 06/12/2019 16:30, boltar@nowhere.co.uk wrote:
>> On Fri, 6 Dec 2019 16:20:07 +0000
>> Bart <bc@freeuk.com> wrote:
>>> On 04/12/2019 08:40, Paavo Helde wrote:
>
>>>> This is basically so because long happened to be 32-bit in 16-bit DOS 35
>>>> years ago, and MS used it a lot instead of 16-bit int (which was indeed
>>>> unusable for many purposes). As a result, now they cannot change 'long'
>>>> to 64-bit because they have abused it so much.
>>>>
>>>
>>> At least, on Windows 'long' is consistently 32-bit.
>>>
>>> On Linux, as I understand it, 'long' is either 32 bits or 64 bits,
>>> depending on whether the OS is 32 or 64 bits.
>>>
>>> This means that if you use 'long' on Linux64, and depend on it being 64
>>> bits, the same program might not work properly on Linux32.
>>>
>>> And if a 'long' is wide enough on Linux32, then on Linux64 it will
>>> wastefully be 64 bits (ie. an array of 'long' takes twice the memory).
>>>
>>> (Suggestion: don't bother with 'long' at all; either use plain int (32
>>> bits on most relevant machines), or long long int (64 bits), which has
>>> the -LL suffix for constants that need to be considered 64 bits.)
>> 
>> #include <stdint.h>
>> 
>> int32_t myint;
>> int64_t mylong;
>
>So, do you write 3, 3L or 3LL if you wanted three be considered a 'long' 
>type in calculations?
>
>If you need to use a format code (I don't know how much that is still 
>prevalent in C++), is it %d, %ld or %lld?

I still use printf, cout is bloody awful for simple text formatting. I've
seen multiple lines of setfill, setwidth etc loads of times, all of which could
have been done with something like a 20 char printf format.

But yes, officially you need to know the size of what you're passing to printf
(and scanf) so it outputs correctly, though given both are built into the
compiler I imagine the compiler could be a bit smart about it and promote/demote
as appropriate but I don't know how often thats done, if ever.

>> Sorted.
>
>You use a library where the author also 'sorted' by using a type 'mylong'.

stdint.h is an official standard header file and has been for decades.

Back to comp.lang.c++ | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

What does the "L" mean T <T@invalid.invalid> - 2019-12-03 23:38 -0800
  Re: What does the "L" mean Bonita Montero <Bonita.Montero@gmail.com> - 2019-12-04 08:43 +0100
    Re: What does the "L" mean T <T@invalid.invalid> - 2019-12-04 00:05 -0800
      Re: What does the "L" mean Geoff <geoff@invalid.invalid> - 2019-12-04 00:32 -0800
        Re: What does the "L" mean T <T@invalid.invalid> - 2019-12-04 00:33 -0800
        Re: What does the "L" mean Paavo Helde <myfirstname@osa.pri.ee> - 2019-12-04 11:11 +0200
          Re: What does the "L" mean Geoff <geoff@invalid.invalid> - 2019-12-04 01:14 -0800
      Re: What does the "L" mean "Fred. Zwarts" <F.Zwarts@KVI.nl> - 2019-12-04 09:39 +0100
        Re: What does the "L" mean T <T@invalid.invalid> - 2019-12-04 00:51 -0800
      Re: What does the "L" mean Paavo Helde <myfirstname@osa.pri.ee> - 2019-12-04 10:40 +0200
        Re: What does the "L" mean T <T@invalid.invalid> - 2019-12-04 00:56 -0800
          Re: What does the "L" mean Bo Persson <bo@bo-persson.se> - 2019-12-04 10:08 +0100
            Re: What does the "L" mean T <T@invalid.invalid> - 2019-12-04 01:20 -0800
              Re: What does the "L" mean Vir Campestris <vir.campestris@invalid.invalid> - 2019-12-04 21:46 +0000
                Re: What does the "L" mean Ben Bacarisse <ben.usenet@bsb.me.uk> - 2019-12-05 01:33 +0000
                Re: What does the "L" mean Vir Campestris <vir.campestris@invalid.invalid> - 2019-12-05 15:15 +0000
                Re: What does the "L" mean Ben Bacarisse <ben.usenet@bsb.me.uk> - 2019-12-05 15:31 +0000
                Re: What does the "L" mean Vir Campestris <vir.campestris@invalid.invalid> - 2019-12-06 10:59 +0000
                Re: What does the "L" mean Ben Bacarisse <ben.usenet@bsb.me.uk> - 2019-12-07 03:55 +0000
                Re: What does the "L" mean James Kuyper <jameskuyper@alumni.caltech.edu> - 2019-12-06 23:38 -0500
                Re: What does the "L" mean Tim Rentsch <tr.17687@z991.linuxsc.com> - 2019-12-06 22:36 -0800
                Re: What does the "L" mean Vir Campestris <vir.campestris@invalid.invalid> - 2019-12-08 21:33 +0000
                Re: What does the "L" mean Bart <bc@freeuk.com> - 2019-12-06 20:44 +0000
                Re: What does the "L" mean Bart <bc@freeuk.com> - 2019-12-06 20:52 +0000
                Re: What does the "L" mean Tim Rentsch <tr.17687@z991.linuxsc.com> - 2019-12-06 22:20 -0800
        Re: What does the "L" mean Bart <bc@freeuk.com> - 2019-12-06 16:20 +0000
          Re: What does the "L" mean boltar@nowhere.co.uk - 2019-12-06 16:30 +0000
            Re: What does the "L" mean Bart <bc@freeuk.com> - 2019-12-06 17:50 +0000
              Re: What does the "L" mean scott@slp53.sl.home (Scott Lurndal) - 2019-12-06 18:18 +0000
              Re: What does the "L" mean boltar@nowhere.co.uk - 2019-12-07 11:57 +0000
                Re: What does the "L" mean Bart <bc@freeuk.com> - 2019-12-07 12:04 +0000
                Re: What does the "L" mean boltar@nowhere.co.uk - 2019-12-07 13:05 +0000
                Re: What does the "L" mean Bart <bc@freeuk.com> - 2019-12-07 13:16 +0000
                Re: What does the "L" mean Öö Tiib <ootiib@hot.ee> - 2019-12-07 05:49 -0800
          Re: What does the "L" mean scott@slp53.sl.home (Scott Lurndal) - 2019-12-06 16:36 +0000
      Re: What does the "L" mean Bonita Montero <Bonita.Montero@gmail.com> - 2019-12-04 13:47 +0100
        Re: What does the "L" mean Thiago Adams <thiago.adams@gmail.com> - 2019-12-04 04:57 -0800
        Re: What does the "L" mean "Fred. Zwarts" <F.Zwarts@KVI.nl> - 2019-12-04 14:41 +0100
          Re: What does the "L" mean Bonita Montero <Bonita.Montero@gmail.com> - 2019-12-04 15:06 +0100
        Re: What does the "L" mean James Kuyper <jameskuyper@alumni.caltech.edu> - 2019-12-04 08:55 -0500
    Re: What does the "L" mean T <T@invalid.invalid> - 2019-12-04 00:34 -0800
  Re: What does the "L" mean Keith Thompson <kst-u@mib.org> - 2019-12-04 08:28 -0800
    Re: What does the "L" mean Robert Wessel <robertwessel2@yahoo.com> - 2019-12-05 09:32 -0600
      Re: What does the "L" mean Keith Thompson <kst-u@mib.org> - 2019-12-05 10:03 -0800

csiph-web