Size or length

Just starting out? Need help? Post your questions and find answers here.
Wolfram
Enthusiast
Enthusiast
Posts: 568
Joined: Thu May 30, 2013 4:39 pm

Size or length

Post by Wolfram »

Is there a rule, when to name it size and when length?

If we talk about a string it is string length, if we talk about a file it is file size.
Is any rule for that?
macOS Catalina 10.15.7
Dude
Addict
Addict
Posts: 1907
Joined: Mon Feb 16, 2015 2:49 pm

Re: Size or length

Post by Dude »

There's no standard rule. I say string size instead of string length sometimes. It's interchangable.
User avatar
nco2k
Addict
Addict
Posts: 1344
Joined: Mon Sep 15, 2003 5:55 am

Re: Size or length

Post by nco2k »

personally, i stick with size in bytes, and length in characters. for arrays etc. i use count as the total number of elements, and bound for the last accessible index (count - 1).

c ya,
nco2k
If OSVersion() = #PB_OS_Windows_ME : End : EndIf
Bitblazer
Enthusiast
Enthusiast
Posts: 736
Joined: Mon Apr 10, 2017 6:17 pm
Location: Germany
Contact:

Re: Size or length

Post by Bitblazer »

Size and Length are often different things. The Length of "hello" is obviously 5, but the size (to me) could be 5, 6, 10, 12, 20 or 24 Bytes because that depends on the required storage Unit for each character and if additional info is needed like a terminating zero. At least that definition is unambiguous / clear.


ps: I'm glad we usually don't need to discuss the size of a byte anymore as we commonly assume a byte to be 8 bit's nowadays.
https://en.wikipedia.org/wiki/Byte
pps: like nco said
Post Reply