• Home
  • Basics
  • DSA
  • MAD
  • Concept
  • Practice
  • Misc
  • Tips
  • QA’s
  • Home
  • Basics
  • DSA
  • MAD
  • Concept
  • Practice
  • Misc
  • Tips
  • QA’s
  • #News
  • #APPS
  • #Events
    • #WWDC
    • #I/O
    • #Ignite
  • #Let’s Talk
  • #Interview
  • #Tips

MyCodeTips mycodetips-newlogocopy1

  • Home
  • Basics
  • DSA
  • MAD
  • Concept
  • Practice
  • Misc
  • Tips
  • QA’s
Programming, Tips&Tricks

What is Floating-Point Operations

What is Floating-Point Operations

What is Floating-Point Operations

Floating-point values do not follow the rules of integer division—that is, dividing by floating-point values produces floating-point results.

Type float
In certain programming languages (Java comes to mind) the float type is almost never used. In Objective-C, it is the more commonly used of the two—both for practical and memory reasons.

A floating point number must contain a decimal portion, but you can omit digits before or after the decimal point—obviously, not both. The entire number ca be prefixed by a negative sign. Therefore, 3., 1.8, .295, and -.59 are all valid floating point numbers. To display floats in an NSLog call, use %f.

Scientific Notation
As you may recall from a high-school math class, scientific notation is a method of writing absurdly large or small numbers. It takes the form 5.925×102, where the general notation is of a floating-point value followed by a multiplication, a number (generally a power of 10), and an exponent. This number is written in code with the form 5.925e4. The e, formally known as the mantissa, can be written as a capital or lowercase. The mantissa can be either positive or negative; a negative value, such as 2.25e-3, would correspond to a value of 2.25×10-3, or 0.00225.

To display scientific notation, use %e. Alternatively, you can use %g to have NSLog decide whether to display the usual value or the scientific notation—if the exponent is less than -4 or greater than 5, the scientific notation is used; otherwise, the standard floating point notation is used.

Type double
A double value is a more precise float value—the former stores twice as many digits, and on most systems it uses 64 bits.

Like Java, all floating point constants in Objective-C are double. To force a float, append either f or F to the end of the floating point value. Unlike Java, however, floats are used as a general data type for floating-point variables, due to the fact that they require less memory. The distinction is that of constants versus that of variables.

  • Click to share on Reddit (Opens in new window)
  • Click to share on Facebook (Opens in new window)
  • Click to share on Twitter (Opens in new window)
  • Click to share on LinkedIn (Opens in new window)
  • Click to share on Tumblr (Opens in new window)
  • More
  • Click to share on Pocket (Opens in new window)
  • Click to share on Pinterest (Opens in new window)
Written by Admin Blogger - September 2, 2019 - 1577 Views
Tags | JAVA, objective-c
AUTHOR
Admin Blogger

This website is basically about of what we learnt from my years of experience as a software engineer on software development specifically on mobile application development, design patterns/architectures and its changing scenarios, security, troubleshooting, tools, tips&tricks and many more.

You Might Also Like

Passing data between view controllers in Objective-C

Passing data between view controllers in Objective-C

November 23, 2021
objective-c-control-statements2

Objective-C control statements and loops !

October 21, 2021
objective-cheatsheet

Cheatsheet of Objective-C

August 17, 2021
Next Post
Previous Post

Support us

Subscribe for updates

Join 8,276 other subscribers

Latest Posts

  • primitive-datatypes-new
    Exploring the Pros and Cons of Primitive Data Types
  • best practice clean code
    Essential Coding Standards and Best Practices for Clean Code
  • YT-Featured-Templates--lld
    What Business Problems Solves in Low Level Design (LLD)
  • SRP-SingleResopnsibility
    SRP : Single Responsibility Principle in Swift and Objective-C
  • Designing Mobile APPS
    Limitation and restriction of designing mobile apps
whiteboard

Whiteboard(PRO)

whiteboard

Whiteboard(lite)

alphabets

Kids Alphabet

do2day

Do2Day

  • #about
  • #myapps
  • #contact
  • #privacy
  • #Advertise
  • #myQuestions

.Net Android Blogging Cloud Concept Database DSA ERROR ExcelTips Flutter Interview IOS IOSQuestions JAVA Javascript MAC-OS No-Mouse Objective-c Programming Quick Tips SEO Software Design & Architecture Swift SwiftUI Tips&Tricks Tools Troubleshoot Videos Web Wordpress Xamarin XCode

  • Exploring the Pros and Cons of Primitive Data Types
  • Essential Coding Standards and Best Practices for Clean Code
  • What Business Problems Solves in Low Level Design (LLD)
  • SRP : Single Responsibility Principle in Swift and Objective-C
  • Limitation and restriction of designing mobile apps
MyCodeTips

©mycodetips.com