How can you prove that multiplication with floating-point numbers creates more inaccuracy than addition/subtraction?

Advertisements I just started reading about the inaccuracies with writing decimals in binary. Then I was given this challenge: You are given two functions which take float inputs a and b and returns the value a ** 2 – b ** 2. There are two ways to calculate this: (a + b) * (a -… Read More How can you prove that multiplication with floating-point numbers creates more inaccuracy than addition/subtraction?

Why I don't get floating point number when i divide (float) number by (float) number?

Advertisements I had a function (money) needs two parameters (salary, days) every week there are 2 holidays so working days = days – (weeks * 2) you only spend money on working days i want to calculate how much money do you spend per day so i did –> salary / working days = sometimes… Read More Why I don't get floating point number when i divide (float) number by (float) number?

How to use big.js?

Advertisements From the examples of big.js they show this example 0.3 – 0.1 // 0.19999999999999998 x = new Big(0.3) x.minus(0.1) // "0.2" x // "0.3" x.div(y).plus(z).times(9).minus(‘1.234567801234567e+8’).plus(976.54321).div(‘2598.11772’) Which is a very simple example. In my case I would like to calculate res = a + (b / c) + (d + 1) / (e * f… Read More How to use big.js?

Building code for counting the number of decimal places in Java

Advertisements I am now trying to build a source code for counting the number of decimal places of floating point value input by the user. Below is my code written in Java: import java.util.Scanner; import java.lang.Math; class CountDecimalPlaces{ public static void main(String[] args){ Scanner input = new Scanner(System.in); double double1 = input.nextDouble(); int int1 =… Read More Building code for counting the number of decimal places in Java

Not able to 'numpy.float64' to int in python

Advertisements I am trying to convert ‘numpy.float64’ to float to do this: ax.get_ylim()[0].astype(float) Which prints out -2.25 But when I check with type(ax.get_ylim()[0].astype(float)) it is printing out numpy.float64. Why is it not changing the data type? >Solution : Can you try the following: float(ax.get_ylim()[0])