[Oberon] ReadInt vs ReadNum

Jörg Straube joerg.straube at iaeth.ch
Sun Jun 19 09:47:15 CEST 2016


If you want to exchange files between machines with different endianess don't use ReadInt/WriteInt. Those procedures only work between machines with the same endianess.

ReadNum/WriteNum define a true presentation layer with a clear semantic. The LONGINTs are encoded very compactly.

Jörg

> Am 19.06.2016 um 09:20 schrieb Srinivas Nayak <sinu.nayak2001 at gmail.com>:
> 
> Dear Chris,
> 
> Many thanks for your quick reply.
> Now I see, WriteNum/ReadNum are indeed awesome features.
> 
> 
> With thanks and best regards,
> 
> Yours sincerely,
> Srinivas Nayak
> 
> Home: http://www.mathmeth.com/sn/
> Blog: http://srinivas-nayak.blogspot.in/
> 
> On 06/19/2016 12:23 PM, Chris Burrows wrote:
>>> -----Original Message-----
>>> From: Oberon [mailto:oberon-bounces at lists.inf.ethz.ch] On Behalf Of
>>> Srinivas Nayak
>>> Sent: Sunday, 19 June 2016 3:10 PM
>>> To: ETH Oberon and related systems
>>> Subject: [Oberon] ReadInt vs ReadNum
>>> 
>>> What is the difference between Files.ReadInt and Files.ReadNum?
>>> Where to use which one?
>> 
>> Use Files.ReadInt if Files.WriteInt was used to write to the file you are
>> reading from and Files.ReadNum if Files.WriteNum was used.
>> 
>> Assuming 32 bit integers, WriteNum uses from 1 to 5 bytes to store the
>> integer depending on its size whereas WriteInt always uses 4 bytes.
>> 
>> Hence, you would use WriteNum to write integers to a file if your data
>> contained a majority of small integers and you wanted smaller file sizes and
>> faster read / write times.
>> 
>> 
>> Regards,
>> Chris
>> 
>> Chris Burrows
>> CFB Software
>> http://www.astrobe.com
>> 
>> 
>> 
>> 
>> 
>> --
>> Oberon at lists.inf.ethz.ch mailing list for ETH Oberon and related systems
>> https://lists.inf.ethz.ch/mailman/listinfo/oberon
> --
> Oberon at lists.inf.ethz.ch mailing list for ETH Oberon and related systems
> https://lists.inf.ethz.ch/mailman/listinfo/oberon
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 2380 bytes
Desc: not available
URL: <http://lists.inf.ethz.ch/pipermail/oberon/attachments/20160619/fe1addc6/attachment.p7s>


More information about the Oberon mailing list