## Adding a floating number and I'm getting an error

adding floating point numbers calculator
floating point calculator
floating point addition steps
floating point subtraction
floating point addition and subtraction flowchart
floating-point to integer conversion
floating point representation
floating point multiplication

I have tried to figure out what I did wrong but when I try the code different ways it gives an error or wrong result I'm looking for.

```#!/usr/bin/env python3

tax = 0.06

def sales_tax(total):
sales_tax = total * tax
return total

def main():
print("Sales Tax Calculator\n")
total = float(input("Enter total: "))
total_after_tax =(total+sales_tax)
print("Total after tax: ", total_after_tax)

if __name__ == "__main__":
main()
```

then I tired to do it like this but it just added the total + total.

```#!/usr/bin/env python3

tax = 0.06

def sales_tax(total):
sales_tax = total * tax
return total

def main():
print("Sales Tax Calculator\n")
total = float(input("Enter total: "))
total_after_tax =(total+sales_tax(total))
print("Total after tax: ", total_after_tax)

if __name__ == "__main__":
main()
```

Any help or guidance would be much appreciatederror I'm getting.

```tax = 0.06

def sales_tax(total):
sales_tax = total * tax
return sales_tax

def main():
print("Sales Tax Calculator\n")
total = float(input("Enter total: "))
total_after_tax =(total+sales_tax(total))
print("Total after tax: ", total_after_tax)

if __name__ == "__main__":
main()

try this code, it is working properly.
In your sales_tax function u are returning total instead of sales_tax
```

Binary 7 – Floating Point Binary Addition, In particular, this video covers adding together floating point binary numbers for a given sized Duration: 11:16 Posted: May 28, 2018 Floating-point expansions are another way to get a greater precision, benefiting from the floating-point hardware: a number is represented as an unevaluated sum of several floating-point numbers. An example is double-double arithmetic , sometimes used for the C type long double .

In the second code-block, you are setting `sales_tax = total * tax`, but then you just return the original `total`. That means the value of `sales_tax(total)` will just be the original `total.` If you return `total * tax` instead of `total`, then this will work.

Addition and Subtraction, Floating point addition is analogous to addition using scientific notation. For example, to add 2.25x Add the numbers with decimal points aligned: tabular1021. We use the `dc` calculator by placing the two operands on the stack and adding the two top of stack elements. And prior to adding, we place a string `sum=` on the stack, and immediately print it which as a side effect also removes it from the stack. The precision of the results is set to 2.

```tax = 0.06

def sales_tax(total):
return total*tax

def main():
print("Sales Tax Calculator\n")
total = float(input("Enter total: "))
total_after_tax =(total+sales_tax(total))
print("Total after tax: ", total_after_tax)

if __name__ == "__main__":
main()
```

[PDF] “Floating Point Addition Example”, Add the floating point numbers 3.75 and 5.125 to get 8.875 by directly manipulating the numbers in IEEE format. Step 1: Decompose Operands (and add implicit 1). Floating Point Numbers. Floating point numbers are different from integer numbers in that they contain fractional parts. Even if the number to the right of the decimal point is 0 (or decimal comma, if your locale uses commas instead of periods), it's still a fractional part of the number. Floating point numbers can be positive or negative.

Floating Point Numbers, Floating Point Addition. Rewrite the smaller number such that its exponent matches with the exponent of the larger number. 8.70 � 10-1 = 0.087 � 101. Add the mantissas. 9.95 + 0.087 = 10.037 and write the sum 10.037 � 101. Put the result in Normalised Form. Round the result. An IEEE 754 standard floating point binary word consists of a sign bit, exponent, and a mantissa as shown in the figure below. IEEE 754 single precision floating point number consists of 32 bits of which 1 bit = sign bit(s). 8 = Biased exponent bits (e) 23 = mantissa (m). Fig 1: IEEE 754 Floating point standard floating point word

Module 4 Section 3- Floating-point Operations, How does one add floating point numbers? Subtract them? To answer this question, first examine the way you would add the following decimal numbers: 34.568� Math.floor() is used to round an integer or floating point number. It returns the nearest integer rounded down. Math.ceil() can be used to round an integer or floating point number. Unary Operator By adding a + sign before a String, it will be converted into a number if it follows the right format. Multiply by 1

Floating-point arithmetic, in 2005, IBM also added IEEE-compatible decimal floating-point arithmetic. Initially, computers used many different representations for floating-point numbers. The float() method is used to return a floating point number from a number or a string. Syntax: float(x) The method only accepts one parameter and that is also optional to use. Let us look at the various types of argument, the method accepts: A number : Can be an Integer or a floating point number. A String : Must contain numbers of any type.

##### Comments
• In your second code snippet `return sales_tax` instead of `return total`
• The code in your image is different to the code in your post. In your image you have `total+sales_tax` which should be `total+sales_tax(total)`, the same as what you have in your post.
• what is the goal of `sales_tax` function? You are returning `total` so basically you are not doing any operation on it. You should return: `sales_tax` and call the function as `total_after_tax =(total+sales_tax(total))`
• @josh - please take a moment and mark your question as answered. If you were not provided an answer from a member, please answer your question or kindly delete it. Thanks!