question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[@FroMage] We’d like to have a Byte type, even though the traditional bit operators have been stolen by Set. We can probably do with methods for now until by popular request we get them back when everyone realises Set doesn’t need them.

We’re prefer unsigned bytes, which might not be hard to do because the only time we notice that bytes are signed in Java is when doing arithmetic (and our Byte type will not be a Numeric so we’re good), when printing (which we can also fix) and when converting to a number (we can fix that too).

We might want to try to unify Byte with Java’s BitSet, since the former is a fixed-length 8 bit version of the latter. It might even be possible to optimise BitSet operations for native underlying types of corresponding size, such as byte or long.

This is for post-M2.

[Migrated from ceylon/ceylon-spec#183] [Closed at 2014-07-23 10:07:44]

Issue Analytics

  • State:closed
  • Created 12 years ago
  • Comments:101

github_iconTop GitHub Comments

1reaction
CeylonMigrationBotcommented, Nov 14, 2015

[@FroMage] I don’t know what else to add, really. I showed you we already have code that wants to compare bytes, and that it appears to be a common thing to do, and you talk about congruence class. I propose we 1/ make bytes comparable, and 2/ we ban anybody who knows what the fuck a congruence class is from ever using bytes.

0reactions
CeylonMigrationBotcommented, Nov 14, 2015

[@lucaswerkmeister]

we ban anybody who knows what the fuck a congruence class is from ever using bytes.

Eh… in Germany at least, they teach it to us in the first semester of CS studies, so that excludes a lot of people 😃 it’s not that complicated, and Gavin is completely right: Putting some comparison on a type where

  • x.successor > x is sometimes true and sometimes false, and
  • 127.byte < 128.byte could mean either 127 < 128 (true) or 127 < -128 (false)

is crazy.

Now, as to whether an out-of-bounds-for-byte Integer should wrap or not, I personally think that (-1).byte and 500.byte should throw.

But if we have the signedInteger and unsignedInteger attributes, why is (-1).byte not allowed and 255 is allowed? That’s an arbitrary bias to the unsigned representation IMO, whereas I think both representations should be of equal “value”. (Of course, making Bytes Comparable would also introduce this bias.)

Read more comments on GitHub >

github_iconTop Results From Across the Web

Byte - Wikipedia
The byte is a unit of digital information that most commonly consists of eight bits. Historically, the byte was the number of bits...
Read more >
What is byte? A definition from WhatIs.com - TechTarget
In most computer systems, a byte is a unit of data that is eight binary digits long. A byte is the unit most...
Read more >
Bits and Bytes
"Byte" - unit of information storage · A document, an image, a movie .. how many bytes? · 1 byte is enough to...
Read more >
How Bits and Bytes Work - Computer | HowStuffWorks
Bytes and bits are the starting point of the computer world. Find out about the Base-2 system, 8-bit bytes, the ASCII character set,...
Read more >
Python bytes() - Programiz
The bytes() method returns a bytes object of the given size and initialization values. Example 1: Convert string to bytes. string = "Python...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found