小编Jay*_*Dao的帖子

为什么在转换为int之前在变量中存储double表达式会导致与直接转换结果不同的结果?

我编写这个简短的程序来测试从double到int的转换:

int main() {
    int a;
    int d; 
    double b = 0.41;

    /* Cast from variable. */
    double c = b * 100.0;
    a = (int)(c);

    /* Cast expression directly. */
    d = (int)(b * 100.0);

    printf("c = %f \n", c);
    printf("a = %d \n", a);
    printf("d = %d \n", d);

    return 0;
}
Run Code Online (Sandbox Code Playgroud)

输出:

c = 41.000000 
a = 41 
d = 40 
Run Code Online (Sandbox Code Playgroud)

为什么ad具有即使它们两者的产品不同的价值观b100

c floating-point casting

16
推荐指数
1
解决办法
4205
查看次数

aws lambda nodejs - 上传由GULP压缩的zip文件时出错

我正在使用Gulp压缩zip文件,然后将其上传到AWS Lambda.上传zip文件是手动完成的.只有压缩过程由Gulp处理.

这是我的gulpfile.js

var gulp = require('gulp');
var zip = require('gulp-zip');
var del = require('del');
var install = require('gulp-install');
var runSequence = require('run-sequence');
var awsLambda = require("node-aws-lambda");

gulp.task('clean', function() {
  return del(['./dist', './dist.zip']);
});

gulp.task('js', function() {
  return gulp.src('index.js')
    .pipe(gulp.dest('dist/'));
});

gulp.task('npm', function() {
  return gulp.src('./package.json')
    .pipe(gulp.dest('dist/'))
    .pipe(install({production: true}));
});

gulp.task('zip', function() {
  return gulp.src(['dist/**/*', '!dist/package.json'])
    .pipe(zip('dist.zip'))
    .pipe(gulp.dest('./'));
});

gulp.task('deploy', function(callback) {
  return runSequence(
    ['clean'],
    ['js', 'npm'],
    ['zip'],
    callback
  );
});
Run Code Online (Sandbox Code Playgroud)

运行部署任务后,将创建名为dist.zip的zip文件夹,其中包含index.js文件和node_modules文件夹.node_modules文件夹仅包含lodash库.

这是index.js

var _ = require('lodash');

console.log('Loading function');

exports.handler …
Run Code Online (Sandbox Code Playgroud)

gulp aws-lambda

6
推荐指数
1
解决办法
929
查看次数

指向同一数组的指针数组

我读过这样一段Delphi代码:

sample1  = ARRAY[1..80] OF INTEGER; 
psample =^sample1;

VAR
  function :ARRAY[1..70] OF psample;
Run Code Online (Sandbox Code Playgroud)

根据我的理解,程序员试图声明一个包含70个指针的数组,每个指针指向一个sample1数组.

所以当我写:

function[1]^[1] := 5;
function[1]^[2] := 10;
Run Code Online (Sandbox Code Playgroud)

然后 :

function[n]^[1] := 5 
function[n]^[2] := 10; ( n = 2 to 70)
Run Code Online (Sandbox Code Playgroud)

那是对的吗 ?

delphi pascal

5
推荐指数
1
解决办法
210
查看次数

标签 统计

aws-lambda ×1

c ×1

casting ×1

delphi ×1

floating-point ×1

gulp ×1

pascal ×1