Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8201861
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T06:57:40+00:00 2026-06-07T06:57:40+00:00

I am implementing a simple dot product algorithm into actionscript 3.0 codes. Here is

  • 0

I am implementing a simple dot product algorithm into actionscript 3.0 codes. Here is the basic example.

(1, 2, 3) • (7, 9, 11) = 1×7 + 2×9 + 3×11 = 58

I have a simple code here.

public var array1:Array = [1, 2, 3]; // 4, 10, 18
    public var array2:Array = [4, 5, 6];
    public var answer:Number = 0;

    public function Algorithm() 
    {
        multiply();
    }
    public function multiply()
    {
        var temp:Number = 0 ;
        while (temp < array1.length) 
        {
            answer = array1[temp] * array2[temp];
            temp++;

        }
        trace(answer += answer);
    }

But when I trace it..instead of 32, it goes 36… looks like it is adding 4 again for the last answer.

Its bugging me.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T06:57:41+00:00Added an answer on June 7, 2026 at 6:57 am

    You are overwriting answer each time the array loops. The only value that is being stored is the last (3*6 = 18). In your trace you are effectively doubling that, giving you 36 every time. Try this:

    answer = answer + ( array1[temp] * array2[temp] );
    

    Then just trace answer at the end.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i am implementing the simple bubble sort algorithm using CUDA, and i have a
Implementing a simple Login screen using JSF and Spring and Hibernate. I have written
I am implementing a simple version of a linux shell in c. I have
I have tried to find out the working solution for implementing simple events booking
I am implementing a simple cache using LinkedHashMap based on the instructions found here
I am implementing the simple JNI example , as given in http://java.sun.com/docs/books/jni/html/start.html At the
I am considering implementing simple form builder in PHP OOP and integrate it into
I have a problem with implementing a simple NegaMax in my chess programm. According
I'm trying to create JPA class implementing simple interface: public interface Task<T> { public
I'm implementing the simple multiplication algorithm to compare its performance to a divide and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.