Skip to content
  • Home
  • Account
  • Restricted content
  • OBEX
  • Chips Tips
  • Logout
  • Shop
  • Blog
Propeller OBEX
  • OBEX
  • Forum
Login
Propeller OBEX

Propeller 1

  • How to pause in PASM
  • How to choose between VAR and DAT
  • WAITPEQ and WAITPNE with PASM
  • IO pin manipulation using PASM
  • Control IO pins from any cog
  • 3D Models for Parallax Products
  • Implementing Abstract Data Structures with Spin Objects
  • Making in USA - The Parallax 8 core microcontroller
  • Simultaneous pin group control
  • Programming the FLiP module over WiFi
  • Keep any value in range
  • Handy Diagnostic Heartbeat
  • Customer Code Deployment in one click

Propeller 2

  • Floating point operators in SPIN2
  • 64/96/128-Bit Unsigned Integer Math
  • 3D Models for Parallax Products
  • DEBUG Plot Layer and Crop
  • Floating point
  • Getting Started Video Tutorials
  • Using the counter for timeouts
  • asmclk and the automatic clock setter
  • Sharing variables between SPIN2 and PASM2
  • Keep any value in range
  • Determine pin state - High, Low or Floating?
View Categories
  • Home
  • Docs
  • Chips Tips
  • Propeller 2
  • Floating point

Floating point

Reading Time: 1 min read

SPIN2

Introduction #

SPIN2 introduces native 32-bit floating point support for the Propeller 2. The implementation follows IEEE-754 encoding rules, with a bit sequence comprising a sign bit, followed by exponent and then mantissa (significand) bits.

An interesting tool to experiment with the float bit pattern can be found in resources!

Specifications #

Sign Exponent Mantissa (IEEE-754 encoding)S_EEEEEEEE_MMMMMMMMMMMMMMMMMMMMMMM
Largest supported floating point value3.4e+38

Methods #

Floating-point conversion methods

FLOAT(x)
TRUNC(x)
ROUND(x)
NAN(x)        ' Note: run-time only

Operators #

Most SPIN2 floating point operators use the same structure as the corresponding integer based operators, with the addition of a dot character to inform the compiler that float point handling is required.

Floating-point relational operators

<.		
>.
<>.
==.
<=.
>=.

Floating-point unary operators

-. 
FABS(x)
FSQRT(x)

Floating-point binary operators

+. 
-.
*.
/.

Code Snippet #

This example will open a debug terminal window and display the float point results. Copy this code into PNUT, Propeller Tool or SPIN Tools IDE and load it with the DEBUG option enabled to your connected P2

CON
  _clkfreq	= 10_000_000
PUB go(): i
  i := 3.4e+38		' biggest floating-point number possible
  repeat 85		    ' keep dividing it by 10.0 until it's zero
    debug(fdec(i), uhex_long(i))
    i := i /. 10.0

Resources #

Parallax Propeller 2 - Spin2 Language Documentation

Float Bit Pattern - Online Tool


Was this useful ?
Share This Article :
  • Facebook
  • X
  • LinkedIn
Still stuck? How can we help?

Still stuck? How can we help?

Updated on February 2, 2025
DEBUG Plot Layer and CropGetting Started Video Tutorials
Table of Contents
  • Introduction
  • Specifications
  • Methods
  • Operators
  • Code Snippet
  • Resources

Copyright © 2025 - Parallax Inc.
599 Menlo Drive | Rocklin, CA 95765 | USA