Skip to content
geeksforgeeks
  • Tutorials
    • Python
    • Java
    • Data Structures & Algorithms
    • ML & Data Science
    • Interview Corner
    • Programming Languages
    • Web Development
    • CS Subjects
    • DevOps And Linux
    • School Learning
    • Practice Coding Problems
  • Courses
    • DSA to Development
    • Get IBM Certification
    • Newly Launched!
      • Master Django Framework
      • Become AWS Certified
    • For Working Professionals
      • Interview 101: DSA & System Design
      • Data Science Training Program
      • JAVA Backend Development (Live)
      • DevOps Engineering (LIVE)
      • Data Structures & Algorithms in Python
    • For Students
      • Placement Preparation Course
      • Data Science (Live)
      • Data Structure & Algorithm-Self Paced (C++/JAVA)
      • Master Competitive Programming (Live)
      • Full Stack Development with React & Node JS (Live)
    • Full Stack Development
    • Data Science Program
    • All Courses
  • TypeScript
  • Vue.js
  • D3.js
  • Collect.js
  • Underscore.js
  • Moment.js
  • Ember.js
  • Tensorflow.js
  • Fabric.js
  • JS Formatter
  • JavaScript
  • Web Technology
Open In App
Next Article:
D3.js fsum() Method
Next article icon

D3.js fsum() Method

Last Updated : 23 Sep, 2020
Comments
Improve
Suggest changes
Like Article
Like
Report

With the help of d3.fsum() method, we can get the  full precision sum of a floating point array values by using this method and return sum of all the values.

Syntax:

d3.fsum([values])  
Parameter: This function has the following parameter as mentioned above and described below:
  • values: It is an array of values which is passed as parameter.

Return Value: It return the full precision sum of values in an array.

Note: To execute the below examples, you have to install the d3 library by using this command prompt we have to execute the following command.

npm install d3  

Example 1: In this example, we can see that by using d3.fsum() method, we are able to compute the full precision sum of floating point values in an array by using this method.

Filename: index.js javascript
// Defining d3 contrib variable   var d3 = require('d3');  var gfg = d3.fsum([5.4, 4.5, 21.3, -1.9998372, 1.01])  console.log(gfg) 

Output:

30.210162800000003  
Example 2: Filename: index.js javascript
// Defining d3 variable   var d3 = require('d3');  var arr = [] for(var i = 0; i < 5; i++) {     arr.push(i); }  var gfg = d3.fsum(arr)  console.log(gfg) 

Output:

10

Note: The above program will compile and run by using the following command:

node index.js

Reference: https://github.com/d3/d3-array/blob/master/README.md


Next Article
D3.js fsum() Method

J

Jitender_1998
Improve
Article Tags :
  • JavaScript
  • Web Technologies
  • D3.js

Similar Reads

    D3.js cumsum() Method
    With the help of d3.cumsum() method, we can get the cumulative sum of all the values of an array, that is the value at ith index is the cumulative sum of values from index 0 to index i by using this method. Syntax: d3.cumsum( iterable ) Parameter: This function has the following parameter as mention
    2 min read
    D3.js Adder() Method
    With the help of d3.Adder() method, we can get the adder to compute the full precision sum of floating point values and set 0 as a default value by using this method. Syntax: const adder = new d3.Adder() Parameter: This function has no parameters. Return Value: It returns the adder to compute the fu
    2 min read
    D3.js count() method
    With the help of d3.count() method, we can get the count of valid values in the specified iterable data structure. Syntax: d3.count(iterable[, accessor]) Return value: It returns the count of valid values. Note: To execute the below examples you have to install the d3 library by using the command pr
    1 min read
    Node.js fs.fstat() Method
    The fs.fstat() method is used to return information about the given file descriptor. The fs.Stat object returned has several fields and methods to get more details about the file. Syntax: fs.fstat( fd, options, callback ) Parameters: This method accepts three parameters as mentioned above and descri
    3 min read
    Node.js fs.stat() Method
    The fs.stat() method is used to return information about the given file or directory. It returns an fs.Stat object which has several properties and methods to get details about the file or directory. Syntax:fs.stat( path, options, callback )Parameters: This method accept three parameters as mentione
    3 min read
geeksforgeeks-footer-logo
Corporate & Communications Address:
A-143, 7th Floor, Sovereign Corporate Tower, Sector- 136, Noida, Uttar Pradesh (201305)
Registered Address:
K 061, Tower K, Gulshan Vivante Apartment, Sector 137, Noida, Gautam Buddh Nagar, Uttar Pradesh, 201305
GFG App on Play Store GFG App on App Store
Advertise with us
  • Company
  • About Us
  • Legal
  • Privacy Policy
  • In Media
  • Contact Us
  • Advertise with us
  • GFG Corporate Solution
  • Placement Training Program
  • Languages
  • Python
  • Java
  • C++
  • PHP
  • GoLang
  • SQL
  • R Language
  • Android Tutorial
  • Tutorials Archive
  • DSA
  • Data Structures
  • Algorithms
  • DSA for Beginners
  • Basic DSA Problems
  • DSA Roadmap
  • Top 100 DSA Interview Problems
  • DSA Roadmap by Sandeep Jain
  • All Cheat Sheets
  • Data Science & ML
  • Data Science With Python
  • Data Science For Beginner
  • Machine Learning
  • ML Maths
  • Data Visualisation
  • Pandas
  • NumPy
  • NLP
  • Deep Learning
  • Web Technologies
  • HTML
  • CSS
  • JavaScript
  • TypeScript
  • ReactJS
  • NextJS
  • Bootstrap
  • Web Design
  • Python Tutorial
  • Python Programming Examples
  • Python Projects
  • Python Tkinter
  • Python Web Scraping
  • OpenCV Tutorial
  • Python Interview Question
  • Django
  • Computer Science
  • Operating Systems
  • Computer Network
  • Database Management System
  • Software Engineering
  • Digital Logic Design
  • Engineering Maths
  • Software Development
  • Software Testing
  • DevOps
  • Git
  • Linux
  • AWS
  • Docker
  • Kubernetes
  • Azure
  • GCP
  • DevOps Roadmap
  • System Design
  • High Level Design
  • Low Level Design
  • UML Diagrams
  • Interview Guide
  • Design Patterns
  • OOAD
  • System Design Bootcamp
  • Interview Questions
  • Inteview Preparation
  • Competitive Programming
  • Top DS or Algo for CP
  • Company-Wise Recruitment Process
  • Company-Wise Preparation
  • Aptitude Preparation
  • Puzzles
  • School Subjects
  • Mathematics
  • Physics
  • Chemistry
  • Biology
  • Social Science
  • English Grammar
  • Commerce
  • World GK
  • GeeksforGeeks Videos
  • DSA
  • Python
  • Java
  • C++
  • Web Development
  • Data Science
  • CS Subjects
@GeeksforGeeks, Sanchhaya Education Private Limited, All rights reserved
We use cookies to ensure you have the best browsing experience on our website. By using our site, you acknowledge that you have read and understood our Cookie Policy & Privacy Policy
Lightbox
Improvement
Suggest Changes
Help us improve. Share your suggestions to enhance the article. Contribute your expertise and make a difference in the GeeksforGeeks portal.
geeksforgeeks-suggest-icon
Create Improvement
Enhance the article with your expertise. Contribute to the GeeksforGeeks community and help create better learning resources for all.
geeksforgeeks-improvement-icon
Suggest Changes
min 4 words, max Words Limit:1000

Thank You!

Your suggestions are valuable to us.

What kind of Experience do you want to share?

Interview Experiences
Admission Experiences
Career Journeys
Work Experiences
Campus Experiences
Competitive Exam Experiences