# Byte size shortened

**URL:** <https://discourse.processing.org/t/byte-size-shortened/13765>\
**Category:** Coding Questions\
**Created:** [September 2, 2019, 12:04pm UTC](https://discourse.processing.org/t/byte-size-shortened/13765 "2019-09-02T12:04:04Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![GoToLoop](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/gotoloop/32/86_2.png) [@GoToLoop](https://discourse.processing.org/u/GoToLoop)\
**Post date:** [September 2, 2019, 1:39pm UTC](https://discourse.processing.org/t/byte-size-shortened/13765/2 "2019-09-02T13:39:48Z")

</div>

- [Forum.Processing.org/two/discussion/12757/transmission-of-a-float-through-a-serial-link#Item\_5](http://Forum.Processing.org/two/discussion/12757/transmission-of-a-float-through-a-serial-link#Item_5)

```auto
// https://Discourse.Processing.org/t/byte-size-shortened/13765/2
// GoToLoop (2019/Sep/02)

import java.nio.ByteBuffer;
import java.nio.FloatBuffer;

static final int BYTES = Float.BYTES;

final byte[] bytes = new byte[BYTES];
final FloatBuffer buf = ByteBuffer.wrap(bytes).asFloatBuffer();

float f;

void setup() {
  println(buf.order(), java.nio.ByteOrder.nativeOrder(), ENTER);

  bytes[0] = (byte) 0xf0;
  bytes[1] = (byte) 0xaa;
  bytes[2] = (byte) 0xf8;
  bytes[3] = (byte) 0x30;

  println(bytes);
  println();

  f = bytes[0] << 030 | bytes[1] << 020 | bytes[2] << 010 | bytes[3];
  println(f); // -2000.0

  f = buf.get(0);
  println(f); // -4.2329994E29

  exit();
}

```

---

_[View the full topic](https://discourse.processing.org/t/byte-size-shortened/13765)._
